static void
TestPrintUnsignedMax()
{
  PoisonOutput();
  sprintf(output, "%" PRIoMAX, uintmax_t(UINTMAX_C(432157943248732)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "14220563454333534"));

  PoisonOutput();
  sprintf(output, "%" PRIuMAX, uintmax_t(UINTMAX_C(325719232983)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "325719232983"));

  PoisonOutput();
  sprintf(output, "%" PRIxMAX, uintmax_t(UINTMAX_C(327281321873)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "4c337ca791"));

  PoisonOutput();
  sprintf(output, "%" PRIXMAX, uintmax_t(UINTMAX_C(912389523743523)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "33DD03D75A323"));
}
示例#2
0
文件: game.cpp 项目: Harrm/TicTacToe
void Game::run() {    
    while(window.isRunning()) {
        auto start = std::clock()/(double)CLOCKS_PER_SEC;

        window.drawFrame();

        auto end = std::clock()/(double)CLOCKS_PER_SEC;
        auto diff = 1/30.0 - (end - start);
        if(diff > 0) {
            std::this_thread::sleep_for(std::chrono::milliseconds(uintmax_t(diff*1000)));
        }
    }
}
void Queue::describe(FILE* Out) {
  fprintf(Out, "**** Queue %p ***\n", (void*)this);
  fprintf(Out, "First = %p, Last = %p\n", (void*)FirstPage.get(),
          (void*)LastPage.get());
  for (AddressType i = 0; i < PageMap.size(); ++i) {
    std::shared_ptr<Page> Pg = PageMap[i].lock();
    if (Pg)
      Pg->describe(Out);
    else
      fprintf(Out, "Page[%" PRIuMAX "] = nullptr", uintmax_t(i));
    fprintf(Out, "\n");
  }
  if (ErrorPage) {
    fputs("Error ", Out);
    ErrorPage->describe(Out);
  }
  fprintf(Out, "*****************\n");
}
void TraceClass::traceHexInternal(charstring Name, uintmax_t Value) {
  indent();
  trace_value_label(Name);
  fprintf(File, "%" PRIxMAX "\n", uintmax_t(Value));
}
void WholeNumSequence_test_readwritenext_stress() {
    std::cout << "Test Routine:\tWholeNumSequence class" << std::endl;
 	std::cout << "\ttargets: operators <<, >>; has_next/fits_next methods"
            << std::endl;
 	std::cout << "\ttype:\tstress" << std::endl;

    std::cout << "Allocating " << SIZE << " bytes in memory... ";
	uint8_t storage[SIZE];
	std::cout << "done." << std::endl;

    WNSeq_t wnseq;
    std::vector<uintmax_t> wnums_copy1, wnums_copy2;
    uintmax_t n;
    std::size_t i;
    bool test_status = true;

    std::cout << "Beginning test." << std::endl;
    while(test_status) {
		// Reset storage values
        std::fill(storage, storage+SIZE, -1);
		wnums_copy1.clear();
		wnums_copy2.clear();
        // Fill number stream with random numbers
		std::cout << "Generating/storing random inputs..." << std::endl;
        wnseq.init(BitSeq_t(storage, storage+SIZE));
        while (n = 1 + (rand() % (uintmax_t(1)<<std::min(SIZE, std::size_t(3)))),//CHAR_BIT*sizeof(uintmax_t)-1))),
				wnseq.write_next(n)) {
            std::cout << '\t' << n << ',';
            wnums_copy1.push_back(n);
        }
        std::cout << "\ndone." << std::endl;
        // Retrieve all numbers from stream
        std::cout << "Reading output list from stream...";
        wnseq.init(BitSeq_t(storage, storage+SIZE));
        while (wnseq.read_next(n)) {
            wnums_copy2.push_back(n);
        }
        std::cout << "done." << std::endl;
        // Compare list copies
        std::cout << "Comparing input/output lists... ";
        test_status = (wnums_copy1 == wnums_copy2);
        if (test_status) {
            std::cout << "Success! (input = output)" << std::endl;
        } else {
            std::cout << "Failure! Output list:" << std::endl;
            for (i = 0; i < std::min(wnums_copy1.size(), wnums_copy2.size()); ++i) {
                std::cout << '\t' << (wnums_copy1[i] != wnums_copy2[i] ? "*":"")
                        << wnums_copy2[i] << ',';
            }
            for (; i < wnums_copy2.size(); ++i) {
                std::cout << "\t*" << wnums_copy2[i] << ',';
            }
            std::cout << std::endl;
			std::cout << "Bits Stored: ";
			BitSeq_t bseq(storage, storage+SIZE);
			while (bseq.has_next()) {
				std::cout << (bseq.read_next() ? '1':'0');
			}
			std::cout << std::endl;
        }
    }
    std::cout << "Exiting test." << std::endl;
}
示例#6
0
            inline uintmax_t cptr()
            {
                BOOST_ASSERT(_pokemon_pc.get() != nullptr);

                return uintmax_t(_pokemon_pc.get());
            }
示例#7
0
 // For equality and hash codes
 uintmax_t cptr()
 {
     return uintmax_t(_daycare.get());
 }