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

Function entropy_coder_kernel_test

dlib/test/entropy_coder.cpp:212–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210 typename decoder
211 >
212 void entropy_coder_kernel_test (
213 )
214 /*!
215 requires
216 - encoder is an implementation of entropy_encoder/entropy_encoder_kernel_abstract.h
217 - decoder is an implementation of entropy_decoder/entropy_decoder_kernel_abstract.h
218 ensures
219 - runs tests on encoder and decoder for compliance with the specs
220 !*/
221 {
222 using namespace entropy_coder_kernel_test_helpers;
223
224 dlog << LTRACE << 1;
225
226 print_spinner();
227 string temp, temp2;
228
229 srand(static_cast<int>(time(0)));
230
231 for (int k = 0; k < 10000; ++k)
232 {
233 string temp;
234 istringstream sin;
235 ostringstream sout;
236 decoder d;
237 encoder e;
238
239 e.set_stream(sout);
240
241 int num = ::rand() %200;
242 unsigned long total[200];
243 unsigned long high_count[200];
244 unsigned long low_count[200];
245 for (int i = 0; i < num; ++i)
246 {
247 total[i] = ::rand()%256 + 20;
248 high_count[i] = ::rand()%total[i] + 1;
249 low_count[i] = ::rand()%high_count[i];
250
251 e.encode(low_count[i],high_count[i],total[i]);
252 }
253
254 e.clear();
255
256 sout.rdbuf()->sputc('a');
257
258 sin.str(sout.str());
259
260
261 d.set_stream(sin);
262
263
264 for (int i = 0; i < num; ++i)
265 {
266 unsigned long N = d.get_target(total[i]);
267 DLIB_TEST(low_count[i] <= N && N < high_count[i]);
268 d.decode(low_count[i],high_count[i]);
269 }

Callers

nothing calls this directly

Calls 7

print_spinnerFunction · 0.85
randClass · 0.50
encodeMethod · 0.45
clearMethod · 0.45
strMethod · 0.45
decodeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected