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

Function rand_test

dlib/test/rand.cpp:88–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 typename rand
87 >
88 void rand_test (
89 )
90 /*!
91 requires
92 - rand is an implementation of rand/rand_kernel_abstract.h
93 is instantiated with int
94 ensures
95 - runs tests on rand for compliance with the specs
96 !*/
97 {
98
99 ostringstream seed;
100 seed << (unsigned int)time(0);
101
102 ostringstream sout;
103
104
105 rand r, r2;
106 DLIB_TEST(r.get_seed() == "");
107 r.set_seed(seed.str());
108
109 DLIB_TEST(r.get_seed() == seed.str());
110 r.clear();
111 DLIB_TEST(r.get_seed() == "");
112 swap(r,r2);
113 DLIB_TEST(r.get_seed() == "");
114 r.set_seed(seed.str());
115 DLIB_TEST(r.get_seed() == seed.str());
116 swap(r,r2);
117 DLIB_TEST(r2.get_seed() == seed.str());
118 DLIB_TEST(r.get_seed() == "");
119 swap(r,r2);
120 DLIB_TEST(r.get_seed() == seed.str());
121 DLIB_TEST(r2.get_seed() == "");
122
123 print_spinner();
124 unsigned long size = 100000;
125 for (unsigned long i = 0; i < size; ++i)
126 {
127 uint32 ch = r.get_random_32bit_number();
128 sout.write((char*)&ch,4);
129 }
130
131 check_bpp(sout.str());
132 sout.clear();
133 sout.str("");
134
135 print_spinner();
136 for (unsigned long i = 0; i < size; ++i)
137 {
138 uint16 ch = r.get_random_16bit_number();
139 sout.write((char*)&ch,2);
140 }
141
142 check_bpp(sout.str());
143 sout.clear();
144 sout.str("");
145

Callers

nothing calls this directly

Calls 15

print_spinnerFunction · 0.85
check_bppFunction · 0.85
absFunction · 0.85
writeMethod · 0.80
get_random_gaussianMethod · 0.80
swapFunction · 0.70
serializeFunction · 0.70
deserializeFunction · 0.70
get_seedMethod · 0.45

Tested by

no test coverage detected