1 /*
2 file automatically generated by make_test_files.pl
3 Tue Apr 19 14:01:02 2011
4 */
5
6 /*****************************************************************************
7 * *
8 * UNU.RAN -- Universal Non-Uniform Random number generator *
9 * *
10 *****************************************************************************/
11
12 /**
13 ** Tests for HIST
14 **/
15
16 /*---------------------------------------------------------------------------*/
17 #include "testunuran.h"
18
19 #ifdef UNUR_URNG_DEFAULT_RNGSTREAM
20 #include <RngStream.h>
21 #endif
22 /*---------------------------------------------------------------------------*/
23
24 /*---------------------------------------------------------------------------*/
25 /* global variables */
26
27 static FILE *TESTLOG; /* test log file */
28 static FILE *UNURANLOG; /* unuran log file */
29
30 static int test_ok = TRUE; /* all tests ok (boolean) */
31 static int fullcheck = FALSE; /* whether all checks are performed */
32
33 static TIMER watch; /* stop watch */
34
35 /*---------------------------------------------------------------------------*/
36
37 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par );
38
39 int unur_hist_set_verify( UNUR_PAR *par, int verify);
40
41
42 /*---------------------------------------------------------------------------*/
43
44 void test_new (void);
45 void test_set (void);
46 void test_get (void);
47 void test_chg (void);
48 void test_init (void);
49 void test_reinit (void);
50 void test_sample (void);
51 void test_validate (void);
52 void test_special(void);
53
54 /*---------------------------------------------------------------------------*/
55
56
57
58 /* prototypes */
59
60 #define COMPARE_SAMPLE_SIZE (10000)
61 #define VIOLATE_SAMPLE_SIZE (20)
62
63 UNUR_DISTR *get_distr_with_data( void );
64 UNUR_DISTR *get_distr_with_data2( void );
65
66
67
68
69 /*---------------------------------------------------------------------------*/
70
71 #ifndef CHI2_FAILURES_TOLERATED
72 # define CHI2_FAILURES_TOLERATED DEFAULT_CHI2_FAILURES_TOLERATED
73 #endif
74
75 /*---------------------------------------------------------------------------*/
76 /* [verbatim] */
77
78
79
80 /*---------------------------------------------------------------------------*/
81
get_distr_with_data(void)82 UNUR_DISTR *get_distr_with_data( void )
83 {
84 #define HIST_SIZE 20
85 double hist[HIST_SIZE];
86 UNUR_DISTR *distr;
87 int i;
88
89 unur_urng_fish_reset(NULL);
90
91 for (i=0; i<HIST_SIZE; i++)
92 hist[i] = (2.*i)/((double)HIST_SIZE) + unur_urng_fish(NULL);
93
94 distr = unur_distr_cemp_new();
95 unur_distr_cemp_set_hist(distr,hist,HIST_SIZE,-2.5,7.5);
96
97 return distr;
98
99 #undef HIST_SIZE
100 } /* end of get_distr_with_data() */
101
102 /*---------------------------------------------------------------------------*/
103
get_distr_with_data2(void)104 UNUR_DISTR *get_distr_with_data2( void )
105 {
106 #define HIST_SIZE 20
107 double hist[HIST_SIZE];
108 UNUR_DISTR *distr;
109 int i;
110
111 unur_urng_fish_reset(NULL);
112
113 for (i=0; i<HIST_SIZE; i++)
114 hist[i] = (2.*i)/((double)HIST_SIZE) + unur_urng_fish(NULL);
115
116 distr = unur_distr_cemp_new();
117 unur_distr_cemp_set_hist_prob(distr,hist,HIST_SIZE);
118 unur_distr_cemp_set_hist_domain(distr,-2.5,7.5);
119
120 return distr;
121
122 #undef HIST_SIZE
123 } /* end of get_distr_with_data2() */
124
125 /*---------------------------------------------------------------------------*/
126
127 /*---------------------------------------------------------------------------*/
128 /* [new] */
129
test_new(void)130 void test_new (void)
131 {
132 int n_tests_failed; /* number of failed tests */
133
134 /* start test */
135 printf("[new "); fflush(stdout);
136 fprintf(TESTLOG,"\n[new]\n");
137
138 /* reset counter */
139 n_tests_failed = 0;
140
141 /* set stop watch */
142 stopwatch_lap(&watch);
143
144 { /* invalid NULL ptr */
145 UNUR_DISTR *distr = NULL;
146 distr = NULL;
147
148
149 unur_reset_errno();
150 n_tests_failed += (check_expected_NULL(TESTLOG,29,(unur_hist_new( distr )))==UNUR_SUCCESS)?0:1;
151 n_tests_failed += (check_errorcode(TESTLOG,29,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
152 unur_distr_free(distr);
153 }
154
155 { /* invalid distribution type */
156 UNUR_DISTR *distr = NULL;
157 distr = unur_distr_cont_new();
158
159
160 unur_reset_errno();
161 n_tests_failed += (check_expected_NULL(TESTLOG,36,(unur_hist_new( distr )))==UNUR_SUCCESS)?0:1;
162 n_tests_failed += (check_errorcode(TESTLOG,36,UNUR_ERR_DISTR_INVALID)==UNUR_SUCCESS)?0:1;
163 unur_distr_free(distr);
164 }
165
166 { /* data missing in distribution object */
167 UNUR_DISTR *distr = NULL;
168 distr = unur_distr_cemp_new(); /* no data given */
169
170
171 unur_reset_errno();
172 n_tests_failed += (check_expected_NULL(TESTLOG,43,(unur_hist_new( distr )))==UNUR_SUCCESS)?0:1;
173 n_tests_failed += (check_errorcode(TESTLOG,43,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
174 unur_distr_free(distr);
175 }
176
177 { /* data missing in distribution object */
178 UNUR_DISTR *distr = NULL;
179 double hist[] = {0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1};
180 distr = unur_distr_cemp_new();
181 unur_distr_cemp_set_hist_prob(distr,hist,9);
182
183
184 unur_reset_errno();
185 n_tests_failed += (check_expected_NULL(TESTLOG,52,(unur_hist_new( distr )))==UNUR_SUCCESS)?0:1;
186 n_tests_failed += (check_errorcode(TESTLOG,52,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
187 unur_distr_free(distr);
188 }
189
190
191 /* timing */
192 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
193
194 /* test finished */
195 test_ok &= (n_tests_failed) ? 0 : 1;
196 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
197
198 } /* end of test_new() */
199
200 /*---------------------------------------------------------------------------*/
201 /* [init] */
202
test_init(void)203 void test_init (void)
204 {
205 int n_tests_failed; /* number of failed tests */
206
207 /* start test */
208 printf("[init "); fflush(stdout);
209 fprintf(TESTLOG,"\n[init]\n");
210
211 /* reset counter */
212 n_tests_failed = 0;
213
214 /* set stop watch */
215 stopwatch_lap(&watch);
216
217 { /* run init */
218 UNUR_DISTR *distr = NULL;
219 UNUR_PAR *par = NULL;
220 UNUR_GEN *gen = NULL;
221 distr = get_distr_with_data();
222 par = unur_hist_new(distr);
223 gen = unur_init( par );
224 abort_if_NULL(TESTLOG, 73, gen );
225
226
227 unur_reset_errno();
228 ;
229 n_tests_failed += (check_errorcode(TESTLOG,77,0x0u)==UNUR_SUCCESS)?0:1;
230 unur_distr_free(distr);
231 unur_free(gen);
232 }
233
234
235 /* timing */
236 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
237
238 /* test finished */
239 test_ok &= (n_tests_failed) ? 0 : 1;
240 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
241
242 } /* end of test_init() */
243
244 /*---------------------------------------------------------------------------*/
245 /* [reinit] */
246
test_reinit(void)247 void test_reinit (void)
248 {
249 int n_tests_failed; /* number of failed tests */
250
251 /* start test */
252 printf("[reinit "); fflush(stdout);
253 fprintf(TESTLOG,"\n[reinit]\n");
254
255 /* reset counter */
256 n_tests_failed = 0;
257
258 /* set stop watch */
259 stopwatch_lap(&watch);
260
261
262 /* timing */
263 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
264
265 /* test finished */
266 test_ok &= (n_tests_failed) ? 0 : 1;
267 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
268
269 } /* end of test_reinit() */
270
271 /*---------------------------------------------------------------------------*/
272 /* [sample] */
273
test_sample(void)274 void test_sample (void)
275 {
276 int n_tests_failed; /* number of failed tests */
277
278 /* start test */
279 printf("[sample "); fflush(stdout);
280 fprintf(TESTLOG,"\n[sample]\n");
281
282 /* reset counter */
283 n_tests_failed = 0;
284
285 /* set stop watch */
286 stopwatch_lap(&watch);
287
288 { /* compare variants */
289 UNUR_PAR *par = NULL;
290 UNUR_GEN *gen = NULL;
291 UNUR_DISTR *distr1 = get_distr_with_data();
292 UNUR_DISTR *distr2 = get_distr_with_data2();
293 par = unur_hist_new(distr1);
294 gen = unur_init( par );
295 abort_if_NULL(TESTLOG, 102, gen );
296
297
298 unur_reset_errno();
299 /* default generator object */;
300 n_tests_failed += (compare_sequence_gen_start(TESTLOG,106,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
301
302 unur_reset_errno();
303 /* variant */
304 unur_free(gen);
305 par = unur_hist_new(distr2);
306 gen = unur_init(par);
307 n_tests_failed += (compare_sequence_gen(TESTLOG,112,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
308 unur_distr_free(distr1);
309 unur_distr_free(distr2);
310 unur_free(gen);
311 }
312
313 { /* compare variant */
314 UNUR_DISTR *distr = NULL;
315 UNUR_PAR *par = NULL;
316 UNUR_GEN *gen = NULL;
317 double hist[] = {0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1};
318 double bins[] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
319 distr = unur_distr_cemp_new();
320 unur_distr_cemp_set_hist_prob(distr,hist,9);
321 unur_distr_cemp_set_hist_domain(distr,1.,10.);
322 par = unur_hist_new(distr);
323 gen = unur_init( par );
324 abort_if_NULL(TESTLOG, 125, gen );
325
326
327 unur_reset_errno();
328 /* default generator object */;
329 n_tests_failed += (compare_sequence_gen_start(TESTLOG,129,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
330
331 unur_reset_errno();
332 /* variant */
333 unur_free(gen);
334 unur_distr_free(distr);
335 distr = unur_distr_cemp_new();
336 unur_distr_cemp_set_hist_prob(distr,hist,9);
337 unur_distr_cemp_set_hist_bins(distr,bins,10);
338 unur_distr_cemp_set_hist_domain(distr,1.,100.);
339 par = unur_hist_new(distr);
340 gen = unur_init(par);
341 n_tests_failed += (compare_sequence_gen(TESTLOG,140,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
342 unur_distr_free(distr);
343 unur_free(gen);
344 }
345
346 { /* compare clone */
347 UNUR_DISTR *distr = NULL;
348 UNUR_PAR *par = NULL;
349 UNUR_GEN *gen = NULL;
350 UNUR_GEN *clone;
351 double hist[] = {0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1};
352 double bins[] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
353 distr = unur_distr_cemp_new();
354 unur_distr_cemp_set_hist_prob(distr,hist,9);
355 unur_distr_cemp_set_hist_bins(distr,bins,10);
356 par = unur_hist_new(distr);
357 gen = unur_init( par );
358 abort_if_NULL(TESTLOG, 151, gen );
359
360
361 unur_reset_errno();
362 /* default generator object */;
363 n_tests_failed += (compare_sequence_gen_start(TESTLOG,155,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
364
365 unur_reset_errno();
366 /* clone */
367 clone = unur_gen_clone(gen);
368 unur_free(gen);
369 gen = clone;
370 n_tests_failed += (compare_sequence_gen(TESTLOG,161,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
371 unur_distr_free(distr);
372 unur_free(gen);
373 }
374
375 { /* compare clone */
376 UNUR_DISTR *distr = NULL;
377 UNUR_PAR *par = NULL;
378 UNUR_GEN *gen = NULL;
379 UNUR_GEN *clone;
380 distr = get_distr_with_data();
381 par = unur_hist_new(distr);
382 gen = unur_init( par );
383 abort_if_NULL(TESTLOG, 168, gen );
384
385
386 unur_reset_errno();
387 /* default generator object */;
388 n_tests_failed += (compare_sequence_gen_start(TESTLOG,172,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
389
390 unur_reset_errno();
391 /* clone */
392 clone = unur_gen_clone(gen);
393 unur_free(gen);
394 gen = clone;
395 n_tests_failed += (compare_sequence_gen(TESTLOG,178,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
396 unur_distr_free(distr);
397 unur_free(gen);
398 }
399
400 { /* compare stringparser */
401 UNUR_DISTR *distr = NULL;
402 UNUR_PAR *par = NULL;
403 UNUR_GEN *gen = NULL;
404 double hist[] = {0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1};
405 distr = unur_distr_cemp_new();
406 unur_distr_cemp_set_hist_prob(distr,hist,9);
407 unur_distr_cemp_set_hist_domain(distr,1.,10.);
408 par = unur_hist_new(distr);
409 gen = unur_init( par );
410 abort_if_NULL(TESTLOG, 187, gen );
411
412
413 unur_reset_errno();
414 /* default generator object */;
415 n_tests_failed += (compare_sequence_gen_start(TESTLOG,191,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
416
417 unur_reset_errno();
418 /* string API */
419 unur_free(gen);
420 gen = unur_str2gen("cemp; hist_prob=(0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1); \
421 hist_domain=(1.,10.) & method = hist");
422 n_tests_failed += (compare_sequence_gen(TESTLOG,197,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
423
424 unur_reset_errno();
425 /* string API */
426 unur_free(gen);
427 gen = unur_str2gen("cemp; hist_prob=(0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1); \
428 hist_bins=(1.,2.,3.,4.,5.,6.,7.,8.,9.,10.) & method = hist");
429 n_tests_failed += (compare_sequence_gen(TESTLOG,203,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
430 unur_distr_free(distr);
431 unur_free(gen);
432 }
433
434
435 /* timing */
436 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
437
438 /* test finished */
439 test_ok &= (n_tests_failed) ? 0 : 1;
440 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
441
442 } /* end of test_sample() */
443
444 /*---------------------------------------------------------------------------*/
445 /* [validate] */
446
447 /*---------------------------------------------------------------------------*/
448
449 /* [validate] */
450
test_validate(void)451 void test_validate (void)
452 {
453 UNUR_DISTR *distr[2];
454 UNUR_PAR *par;
455 UNUR_GEN *gen;
456 int n_tests_failed;
457 int rcode;
458 double *darray;
459 double fpm[10];
460
461 rcode = 0;
462
463 /* start test */
464 printf("[validate "); fflush(stdout);
465 fprintf(TESTLOG,"\n[validate]\n");
466
467 /* reset counter */
468 n_tests_failed = 0;
469
470 /* set stop watch */
471 stopwatch_lap(&watch);
472
473
474 /* distributions: 2 */
475 {
476 { double pv[1000];
477 UNUR_DISTR *normal_dist;
478 int i;
479 double xmin, xmax;
480 double fxmin, fxmax;
481 xmin = -5.;
482 fxmin = 0.;
483 normal_dist = unur_distr_normal(NULL,0);
484 for (i=0; i<1000; i++) {
485 xmax = -5. + i/100.;
486 fxmax = unur_distr_cont_eval_cdf(xmax,normal_dist);
487 pv[i] = fxmax - fxmin;
488 xmin = xmax;
489 fxmin = fxmax; }
490 unur_distr_free(normal_dist);
491 distr[0] = unur_distr_cemp_new();
492 unur_distr_cemp_set_hist(distr[0],pv,1000,-5.,5.); }
493 }
494
495 {
496 { double pv[1000];
497 double bins[1001];
498 UNUR_DISTR *normal_dist;
499 int i;
500 double xmin, xmax;
501 double fxmin, fxmax;
502 normal_dist = unur_distr_normal(NULL,0);
503 bins[500] = 0.;
504 for (i=501; i<=1000; i++)
505 bins[i] = bins[i-1] + (i-500)/25000.;
506 for (i=499; i>=0; i--)
507 bins[i] = bins[i+1] + (i-500)/25000.;
508 xmin = bins[0];
509 fxmin = unur_distr_cont_eval_cdf(xmin,normal_dist);
510 pv[0] = unur_distr_cont_eval_cdf(bins[0],normal_dist);
511 for (i=0; i<1000; i++) {
512 xmax = bins[i+1];
513 fxmax = unur_distr_cont_eval_cdf(xmax,normal_dist);
514 pv[i] = fxmax - fxmin;
515 xmin = xmax;
516 fxmin = fxmax; }
517 unur_distr_free(normal_dist);
518 distr[1] = unur_distr_cemp_new();
519 unur_distr_cemp_set_hist_prob(distr[1],pv,1000);
520 unur_distr_cemp_set_hist_bins(distr[1],bins,1001); }
521 }
522
523 /* timing */
524 stopwatch_print(TESTLOG,"\n<*>setup time = %.3f ms\n", stopwatch_lap(&watch));
525
526 printf("\n(chi^2) "); fflush(stdout);
527
528 /* chi^2 tests: 2 */
529
530 unur_set_default_debug(~UNUR_DEBUG_SAMPLE);
531 fprintf( TESTLOG,"\nChi^2 Test:\n");
532
533 /* distribution [0] */
534
535 if(TRUE) {
536 unur_reset_errno();
537 do {
538 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
539 par = unur_hist_new(distr_localcopy);
540 gen = unur_init(par);
541 rcode = run_validate_chi2(TESTLOG,0,gen,distr[0],'+');
542 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
543 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
544 unur_free(gen);
545 unur_distr_free(distr_localcopy);
546 } while (0);
547 }
548
549 /* distribution [1] */
550
551 if(TRUE) {
552 unur_reset_errno();
553 do {
554 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
555 par = unur_hist_new(distr_localcopy);
556 gen = unur_init(par);
557 rcode = run_validate_chi2(TESTLOG,0,gen,distr[1],'+');
558 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
559 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
560 unur_free(gen);
561 unur_distr_free(distr_localcopy);
562 } while (0);
563 }
564
565 /* timing */
566 stopwatch_print(TESTLOG,"\n<*>time = %.0f ms\n", stopwatch_lap(&watch));
567
568
569 /* free distributions */
570 unur_distr_free(distr[0]);
571 unur_distr_free(distr[1]);
572
573 /* test finished */
574 test_ok &= (n_tests_failed>CHI2_FAILURES_TOLERATED) ? 0 : 1;
575 /* we accept CHI2_FAILURES_TOLERATED failures */
576 (n_tests_failed>CHI2_FAILURES_TOLERATED) ? printf(" ==> failed] ") : printf(" ==> ok] ");
577
578 /* prevent compiler from making useless annoying warnings */
579 distr[0] = NULL;
580 par = NULL;
581 gen = NULL;
582 darray = NULL;
583 fpm[0] = 0.;
584
585 } /* end of test_validate */
586
587
588 /*---------------------------------------------------------------------------*/
589 /* run generator in verifying mode */
590
run_verify_generator(FILE * LOG,int line,UNUR_PAR * par)591 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par )
592 {
593 UNUR_GEN *gen;
594 int i;
595
596 /* switch to verifying mode */
597 unur_hist_set_verify(par,1);
598
599 /* initialize generator */
600 gen = unur_init( par ); abort_if_NULL(LOG, line, gen);
601
602 /* run generator */
603 for (i=0; i<VIOLATE_SAMPLE_SIZE; i++)
604 unur_sample_cont(gen);
605
606 /* destroy generator */
607 unur_free(gen);
608
609 } /* end of run_verify_generator() */
610
unur_hist_set_verify(UNUR_PAR * par ATTRIBUTE__UNUSED,int verify ATTRIBUTE__UNUSED)611 int unur_hist_set_verify(UNUR_PAR *par ATTRIBUTE__UNUSED, int verify ATTRIBUTE__UNUSED) {return 0;}
612
613 /*---------------------------------------------------------------------------*/
614
main(void)615 int main(void)
616 {
617 unsigned long seed;
618 char *str_seed, *str_tail;
619
620 /* start stop watch */
621 stopwatch_init();
622 stopwatch_start(&watch);
623
624 /* open log file for unuran and set output stream for unuran messages */
625 UNURANLOG = fopen( "t_hist_unuran.log","w" );
626 abort_if_NULL( stderr,-1, UNURANLOG );
627 unur_set_stream( UNURANLOG );
628
629 /* open log file for testing */
630 TESTLOG = fopen( "t_hist_test.log","w" );
631 abort_if_NULL( stderr,-1, TESTLOG );
632
633 /* seed for uniform generators */
634
635 /* seed set by environment */
636 str_seed = getenv("SEED");
637
638 if (str_seed != NULL) {
639 seed = strtol(str_seed, &str_tail, 10);
640 if (seed == 0u)
641 seed = 339947;
642 }
643 else {
644 #ifdef SEED
645 seed = SEED;
646 #else
647 seed = 339947;
648 #endif
649 }
650
651 /* seed build-in uniform generators */
652 unur_urng_MRG31k3p_seed(NULL,seed);
653 unur_urng_fish_seed(NULL,seed);
654 unur_urng_mstd_seed(NULL,seed);
655
656 /* seed uniform random number generator */
657 #ifdef UNUR_URNG_UNURAN
658 # ifdef UNUR_URNG_DEFAULT_RNGSTREAM
659 {
660 unsigned long sa[6];
661 int i;
662 for (i=0; i<6; i++) sa[i] = seed;
663 RngStream_SetPackageSeed(sa);
664 }
665 # else
666 if (unur_urng_seed(NULL,seed) != UNUR_SUCCESS) {
667 fprintf(stderr,"WARNING: Seed could not be set at random\n");
668 seed = ~0u;
669 }
670 # endif /* UNUR_URNG_DEFAULT_RNGSTREAM */
671 #endif /* UNUR_URNG_UNURAN */
672
673 /* set default debugging flag */
674 unur_set_default_debug(UNUR_DEBUG_ALL);
675
676 /* detect required check mode */
677 fullcheck = (getenv("UNURANFULLCHECK")==NULL) ? FALSE : TRUE;
678
679 /* write header into log file */
680 print_test_log_header( TESTLOG, seed, fullcheck );
681
682 /* set timer for sending SIGALRM signal */
683 set_alarm(TESTLOG);
684
685 /* start test */
686 printf("hist: ");
687
688 /* run tests */
689 test_new();
690 test_init();
691 test_reinit();
692 test_sample();
693 test_validate();
694
695
696 /* test finished */
697 printf("\n"); fflush(stdout);
698
699 /* close log files */
700 fprintf(TESTLOG,"\n====================================================\n\n");
701 if (test_ok)
702 fprintf(TESTLOG,"All tests PASSED.\n");
703 else
704 fprintf(TESTLOG,"Test(s) FAILED.\n");
705
706 /* timing */
707 stopwatch_print(TESTLOG,"\n<*>total time = %.0f ms\n\n", stopwatch_stop(&watch));
708
709 fclose(UNURANLOG);
710 fclose(TESTLOG);
711
712 /* free memory */
713 compare_free_memory();
714 unur_urng_free(unur_get_default_urng());
715 unur_urng_free(unur_get_default_urng_aux());
716
717 /* exit */
718 exit( (test_ok) ? EXIT_SUCCESS : EXIT_FAILURE );
719
720 } /* end of main */
721
722