93 #include "../src/xrif.h"
95 #include "randutils.h"
97 #ifndef XRIF_TEST_TRIALS
98 #define XRIF_TEST_TRIALS (2)
108 int ws[] = {2,4,8,21, 33, 47, 64};
109 int hs[] = {2,4,8,21, 33, 47, 64};
110 int ps[] = {1,2,4,5,27,63,64};
119 fprintf(stderr,
"Testing first differencing for signed 16-bit white noise.\n");
125 ck_assert( hand != NULL);
128 for(
int q=0; q < test_trials; ++q)
130 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
132 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
134 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
146 int16_t * buffer = (int16_t *) hand->
raw_buffer;
148 ck_assert( rv == 0 );
150 int16_t * compbuff = (int16_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(int16_t));
159 if(buffer[i] != compbuff[i])
164 ck_assert( neq == 0 );
184 fprintf(stderr,
"Testing first differencing for unsigned 16-bit white noise.\n");
190 ck_assert( hand != NULL);
193 for(
int q=0; q < test_trials; ++q)
195 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
197 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
199 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
211 uint16_t * buffer = (uint16_t *) hand->
raw_buffer;
213 ck_assert( rv == 0 );
215 uint16_t * compbuff = (uint16_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(uint16_t));
216 memcpy(compbuff, buffer, hand->
width*hand->
height*hand->
frames*
sizeof(uint16_t));
224 if(buffer[i] != compbuff[i])
229 ck_assert( neq == 0 );
249 fprintf(stderr,
"Testing first differencing for signed 32-bit white noise.\n");
255 ck_assert( hand != NULL);
258 for(
int q=0; q < test_trials; ++q)
260 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
262 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
264 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
276 int32_t * buffer = (int32_t *) hand->
raw_buffer;
278 ck_assert( rv == 0 );
280 int32_t * compbuff = (int32_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(int32_t));
289 if(buffer[i] != compbuff[i])
294 ck_assert( neq == 0 );
314 fprintf(stderr,
"Testing first differencing for unsigned 32-bit white noise.\n");
320 ck_assert( hand != NULL);
323 for(
int q=0; q < test_trials; ++q)
325 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
327 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
329 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
341 uint32_t * buffer = (uint32_t *) hand->
raw_buffer;
343 ck_assert( rv == 0 );
345 uint32_t * compbuff = (uint32_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(uint32_t));
346 memcpy(compbuff, buffer, hand->
width*hand->
height*hand->
frames*
sizeof(uint32_t));
354 if(buffer[i] != compbuff[i])
359 ck_assert( neq == 0 );
379 fprintf(stderr,
"Testing first differencing for signed 64-bit white noise.\n");
385 ck_assert( hand != NULL);
388 for(
int q=0; q < test_trials; ++q)
390 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
392 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
394 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
406 int64_t * buffer = (int64_t *) hand->
raw_buffer;
408 ck_assert( rv == 0 );
410 int64_t * compbuff = (int64_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(int64_t));
419 if(buffer[i] != compbuff[i])
424 ck_assert( neq == 0 );
444 fprintf(stderr,
"Testing first differencing for unsigned 64-bit white noise.\n");
450 ck_assert( hand != NULL);
453 for(
int q=0; q < test_trials; ++q)
455 for(
int w =0; w <
sizeof(ws)/
sizeof(ws[0]); ++w)
457 for(
int h=0; h <
sizeof(hs)/
sizeof(hs[0]); ++h)
459 for(
int p=0; p<
sizeof(ps)/
sizeof(ps[0]); ++p)
471 uint64_t * buffer = (uint64_t *) hand->
raw_buffer;
473 ck_assert( rv == 0 );
475 uint64_t * compbuff = (uint64_t *) malloc( hand->
width*hand->
height*hand->
frames*
sizeof(uint64_t));
476 memcpy(compbuff, buffer, hand->
width*hand->
height*hand->
frames*
sizeof(uint64_t));
484 if(buffer[i] != compbuff[i])
489 ck_assert( neq == 0 );
503 Suite * whitenoise_suite(
void)
506 TCase *tc_core16, *tc_core32, *tc_core64;
508 s = suite_create(
"White Noise - Difference First");
511 tc_core16 = tcase_create(
"16 bit white noise");
513 tcase_set_timeout(tc_core16, 1e9);
515 tcase_add_test(tc_core16, diff_first_int16_white);
516 tcase_add_test(tc_core16, diff_first_uint16_white);
518 suite_add_tcase(s, tc_core16);
521 tc_core32 = tcase_create(
"32 bit white noise");
523 tcase_set_timeout(tc_core32, 1e9);
525 tcase_add_test(tc_core32, diff_first_int32_white);
526 tcase_add_test(tc_core32, diff_first_uint32_white);
528 suite_add_tcase(s, tc_core32);
531 tc_core64 = tcase_create(
"64 bit white noise");
533 tcase_set_timeout(tc_core64, 1e9);
535 tcase_add_test(tc_core64, diff_first_int64_white);
536 tcase_add_test(tc_core64, diff_first_uint64_white);
538 suite_add_tcase(s, tc_core64);
548 extern int test_trials;
550 test_trials = XRIF_TEST_TRIALS;
554 test_trials = atoi(argv[1]);
557 fprintf(stderr,
"running %d trials per format\n", test_trials);
564 srand((
unsigned) time(NULL));
566 s = whitenoise_suite();
567 sr = srunner_create(s);
569 srunner_run_all(sr, CK_NORMAL);
570 number_failed = srunner_ntests_failed(sr);
573 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;