MCPcopy Create free account
hub / github.com/davisking/dlib / outputs_are_not_changed

Function outputs_are_not_changed

dlib/test/rand.cpp:469–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467 }
468
469 void outputs_are_not_changed()
470 {
471 // dlib::rand has been around a really long time and it is a near certainty that there is
472 // client code that depends on dlib::rand yielding the exact random sequence it happens to
473 // yield for any given seed. So we test that the output values of dlib::rand are not
474 // changed in this test.
475
476 {
477 dlib::rand rnd;
478 std::vector<uint32> out;
479 for (int i = 0; i < 30; ++i) {
480 out.push_back(rnd.get_random_32bit_number());
481 }
482
483 const std::vector<uint32> expected = {
484 725333953,251387296,3200466189,2466988778,2049276419,2620437198,2806522923,
485 2922190659,4151412029,2894696296,1344442829,1165961100,328304965,1533685458,
486 3399102146,3995382051,1569312238,2353373514,2512982725,2903494783,787425157,
487 699798098,330364342,2870851082,659976556,1726343583,3551405331,3171822159,
488 1292599360,955731010};
489 DLIB_TEST(out == expected);
490 }
491
492 {
493 dlib::rand rnd;
494 rnd.set_seed("this seed");
495 std::vector<uint32> out;
496 for (int i = 0; i < 30; ++i) {
497 out.push_back(rnd.get_random_32bit_number());
498 }
499
500 const std::vector<uint32> expected = {
501 856663397,2356564049,1192662566,3478257893,1069117227,
502 1922448468,497418632,2504525324,987414451,769612124,77224022,2998161761,
503 1364481427,639342008,1778351952,1931573847,3213816676,3019312695,4179936779,
504 3637269252,4279821094,3738954922,3651625265,3159592157,333323775,4075800582,
505 4237631248,357468843,483435718,1255945812};
506 DLIB_TEST(out == expected);
507 }
508
509 {
510 dlib::rand rnd;
511 rnd.set_seed("some other seed");
512 std::vector<int> out;
513 for (int i = 0; i < 30; ++i) {
514 out.push_back(rnd.get_integer(1000));
515 }
516
517 const std::vector<int> expected = {
518 243,556,158,256,772,84,837,920,767,769,939,394,121,367,575,877,861,506,
519 451,845,870,638,825,516,327,25,646,373,386,227};
520 DLIB_TEST(out == expected);
521 }
522
523 }
524
525 class rand_tester : public tester
526 {

Callers 1

perform_testMethod · 0.85

Calls 4

get_integerMethod · 0.80
push_backMethod · 0.45
set_seedMethod · 0.45

Tested by

no test coverage detected