Imported Upstream version 0.14.0
[platform/upstream/check.git] / tests / check_check_sub.c
1 /*
2  * Check: a unit test framework for C
3  * Copyright (C) 2001, 2002 Arien Malec
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18  * MA 02110-1301, USA.
19  */
20
21 #include "../lib/libcompat.h"
22
23 #include <sys/types.h>
24 #include <stdlib.h>
25 #include <signal.h>
26 #include <check.h>
27 #include "check_check.h"
28
29
30 START_TEST(test_lno)
31 {
32   record_test_name(tcase_name());
33
34   record_failure_line_num(__LINE__);
35   ck_abort_msg("Failure expected");
36 }
37 END_TEST
38
39 #if defined(HAVE_FORK) && HAVE_FORK==1
40 START_TEST(test_mark_lno)
41 {
42   record_test_name(tcase_name());
43
44   record_failure_line_num(__LINE__);
45   mark_point();
46   exit(EXIT_FAILURE); /* should fail with mark_point above as line */
47 }
48 END_TEST
49 #endif /* HAVE_FORK */
50
51 START_TEST(test_pass)
52 {
53   record_test_name(tcase_name());
54
55   ck_assert_msg(1 == 1, "This test should pass");
56   ck_assert_msg(9999, "This test should pass");
57 }
58 END_TEST
59
60 START_TEST(test_fail_unless)
61 {
62   record_test_name(tcase_name());
63
64   record_failure_line_num(__LINE__);
65   fail_unless(1 == 2, "This test should fail");
66 }
67 END_TEST
68
69 START_TEST(test_fail_if_pass)
70 {
71   record_test_name(tcase_name());
72
73   fail_if(1 == 2, "This test should pass");
74   fail_if(0, "This test should pass");
75 }
76 END_TEST
77
78 START_TEST(test_fail_if_fail)
79 {
80   record_test_name(tcase_name());
81
82   record_failure_line_num(__LINE__);
83   fail_if(1 == 1, "This test should fail");
84 }
85 END_TEST
86
87 START_TEST(test_fail_null_msg)
88 {
89   record_test_name(tcase_name());
90
91   record_failure_line_num(__LINE__);
92   fail_unless(2 == 3, NULL);
93 }
94 END_TEST
95
96 #if defined(__GNUC__)
97 START_TEST(test_fail_no_msg)
98 {
99   record_test_name(tcase_name());
100
101   /* taking out the NULL provokes an ISO C99 warning in GCC */
102   record_failure_line_num(__LINE__);
103   fail_unless(4 == 5, NULL);
104 }
105 END_TEST
106 #endif /* __GNUC__ */
107 START_TEST(test_fail_if_null_msg)
108 {
109   record_test_name(tcase_name());
110
111   record_failure_line_num(__LINE__);
112   fail_if(2 != 3, NULL);
113 }
114 END_TEST
115
116 #if defined(__GNUC__)
117 START_TEST(test_fail_if_no_msg)
118 {
119   record_test_name(tcase_name());
120
121   /* taking out the NULL provokes an ISO C99 warning in GCC */
122   record_failure_line_num(__LINE__);
123   fail_if(4 != 5, NULL);
124 }
125 END_TEST
126 #endif /* __GNUC__ */
127 START_TEST(test_fail_vararg_msg_1)
128 {
129   int x = 3;
130   int y = 4;
131
132   record_test_name(tcase_name());
133
134   record_failure_line_num(__LINE__);
135   fail_unless(x == y, "%d != %d", x, y);
136 }
137 END_TEST
138
139 START_TEST(test_fail_vararg_msg_2)
140 {
141   int x = 5;
142   int y = 6;
143
144   record_test_name(tcase_name());
145
146   record_failure_line_num(__LINE__);
147   fail_if(x != y, "%d != %d", x, y);
148 }
149 END_TEST
150
151 START_TEST(test_fail_vararg_msg_3)
152 {
153   int x = 7;
154   int y = 7;
155
156   record_test_name(tcase_name());
157
158   record_failure_line_num(__LINE__);
159   fail("%d == %d", x, y);
160 }
161 END_TEST
162
163 #if defined(__GNUC__)
164 START_TEST(test_fail_empty)
165 {
166   record_test_name(tcase_name());
167
168   /* plain fail() doesn't compile with xlc in C mode because of `, ## __VA_ARGS__' problem */
169   /* on the other hand, taking out the NULL provokes an ISO C99 warning in GCC */
170   record_failure_line_num(__LINE__);
171   fail(NULL);
172 }
173 END_TEST
174 #endif /* __GNUC__ */
175
176 START_TEST(test_ck_abort)
177 {
178   record_test_name(tcase_name());
179
180   record_failure_line_num(__LINE__);
181   ck_abort();
182 }
183 END_TEST
184
185 START_TEST(test_ck_abort_msg)
186 {
187   record_test_name(tcase_name());
188
189   record_failure_line_num(__LINE__);
190   ck_abort_msg("Failure expected");
191 }
192 END_TEST
193
194 /* FIXME: perhaps passing NULL to ck_abort_msg should be an error. */
195 START_TEST(test_ck_abort_msg_null)
196 {
197   record_test_name(tcase_name());
198
199   record_failure_line_num(__LINE__);
200   ck_abort_msg(NULL);
201 }
202 END_TEST
203
204 /* These ck_assert tests are all designed to fail on the last
205    assertion. */
206
207 START_TEST(test_ck_assert)
208 {
209   int x = 3;
210   int y = 3;
211
212   record_test_name(tcase_name());
213
214   ck_assert(1);
215   ck_assert(x == y);
216   y++;
217   ck_assert(x != y);
218   record_failure_line_num(__LINE__);
219   ck_assert(x == y);
220 }
221 END_TEST
222
223 START_TEST(test_ck_assert_null)
224 {
225   record_test_name(tcase_name());
226
227   record_failure_line_num(__LINE__);
228   ck_assert(0);
229 }
230 END_TEST
231
232 START_TEST(test_ck_assert_with_mod)
233 {
234   int f = 1;
235
236   record_test_name(tcase_name());
237
238   record_failure_line_num(__LINE__);
239   ck_assert(1%f == 1);
240 }
241 END_TEST
242
243 START_TEST(test_ck_assert_int_eq)
244 {
245   int x = 3;
246   int y = 3;
247
248   record_test_name(tcase_name());
249
250   ck_assert_int_eq(x, y);
251   y++;
252   record_failure_line_num(__LINE__);
253   ck_assert_int_eq(x, y);
254 }
255 END_TEST
256
257 START_TEST(test_ck_assert_int_eq_with_mod)
258 {
259   int d = 2;
260   int f = 1;
261
262   record_test_name(tcase_name());
263
264   record_failure_line_num(__LINE__);
265   ck_assert_int_eq(3%d, 2%f);
266 }
267 END_TEST
268
269 START_TEST(test_ck_assert_int_ne)
270 {
271   int x = 3;
272   int y = 2;
273
274   record_test_name(tcase_name());
275
276   ck_assert_int_ne(x, y);
277   y++;
278   record_failure_line_num(__LINE__);
279   ck_assert_int_ne(x, y);
280 }
281 END_TEST
282
283 START_TEST(test_ck_assert_int_ne_with_mod)
284 {
285   int d = 2;
286   int f = 2;
287
288   record_test_name(tcase_name());
289
290   record_failure_line_num(__LINE__);
291   ck_assert_int_ne(3%d, 3%f);
292 }
293 END_TEST
294
295 START_TEST(test_ck_assert_int_lt)
296 {
297   int x = 2;
298   int y = 3;
299
300   record_test_name(tcase_name());
301
302   ck_assert_int_lt(x, y);
303   record_failure_line_num(__LINE__);
304   ck_assert_int_lt(x, x);
305 }
306 END_TEST
307
308 START_TEST(test_ck_assert_int_lt_with_mod)
309 {
310   int d = 2;
311   int f = 1;
312
313   record_test_name(tcase_name());
314
315   record_failure_line_num(__LINE__);
316   ck_assert_int_lt(3%d, 3%f);
317 }
318 END_TEST
319
320 START_TEST(test_ck_assert_int_le)
321 {
322   int x = 2;
323   int y = 3;
324
325   record_test_name(tcase_name());
326
327   ck_assert_int_le(x, y);
328   ck_assert_int_le(x, x);
329   record_failure_line_num(__LINE__);
330   ck_assert_int_le(y, x);
331 }
332 END_TEST
333
334 START_TEST(test_ck_assert_int_le_with_mod)
335 {
336   int d = 2;
337   int f = 1;
338
339   record_test_name(tcase_name());
340
341   record_failure_line_num(__LINE__);
342   ck_assert_int_le(3%d, 2%f);
343 }
344 END_TEST
345
346 START_TEST(test_ck_assert_int_gt)
347 {
348   int x = 2;
349   int y = 3;
350
351   record_test_name(tcase_name());
352
353   ck_assert_int_gt(y, x);
354   record_failure_line_num(__LINE__);
355   ck_assert_int_gt(y, y);
356 }
357 END_TEST
358
359 START_TEST(test_ck_assert_int_gt_with_mod)
360 {
361   int d = 1;
362   int f = 2;
363
364   record_test_name(tcase_name());
365
366   record_failure_line_num(__LINE__);
367   ck_assert_int_gt(3%d, 3%f);
368 }
369 END_TEST
370
371 START_TEST(test_ck_assert_int_ge)
372 {
373   int x = 2;
374   int y = 3;
375
376   record_test_name(tcase_name());
377
378   ck_assert_int_ge(y, x);
379   ck_assert_int_ge(y, x);
380   record_failure_line_num(__LINE__);
381   ck_assert_int_ge(x, y);
382 }
383 END_TEST
384
385 START_TEST(test_ck_assert_int_ge_with_mod)
386 {
387   int d = 1;
388   int f = 3;
389
390   record_test_name(tcase_name());
391
392   record_failure_line_num(__LINE__);
393   ck_assert_int_ge(3%d, 4%f);
394 }
395 END_TEST
396
397 START_TEST(test_ck_assert_int_expr)
398 {
399   int x = 1;
400   int y = 0;
401
402   record_test_name(tcase_name());
403
404   ck_assert_int_eq(x, ++y);
405   ck_assert_int_eq(x, y);
406 } END_TEST
407
408 START_TEST(test_ck_assert_uint_eq)
409 {
410   unsigned int x = 3;
411   unsigned int y = 3;
412
413   record_test_name(tcase_name());
414
415   ck_assert_uint_eq(x, y);
416   y++;
417   record_failure_line_num(__LINE__);
418   ck_assert_uint_eq(x, y);
419 }
420 END_TEST
421
422 START_TEST(test_ck_assert_uint_eq_with_mod)
423 {
424   int d = 2;
425   int f = 1;
426
427   record_test_name(tcase_name());
428
429   record_failure_line_num(__LINE__);
430   ck_assert_uint_eq(3%d, 1%f);
431 }
432 END_TEST
433
434 START_TEST(test_ck_assert_uint_ne)
435 {
436   unsigned int x = 3;
437   unsigned int y = 2;
438
439   record_test_name(tcase_name());
440
441   ck_assert_uint_ne(x, y);
442   y++;
443   record_failure_line_num(__LINE__);
444   ck_assert_uint_ne(x, y);
445 }
446 END_TEST
447
448 START_TEST(test_ck_assert_uint_ne_with_mod)
449 {
450   int d = 1;
451   int f = 1;
452
453   record_test_name(tcase_name());
454
455   record_failure_line_num(__LINE__);
456   ck_assert_uint_ne(1%d, 1%f);
457 }
458 END_TEST
459
460 START_TEST(test_ck_assert_uint_lt)
461 {
462   unsigned int x = 2;
463   unsigned int y = 3;
464
465   record_test_name(tcase_name());
466
467   ck_assert_uint_lt(x, y);
468   record_failure_line_num(__LINE__);
469   ck_assert_uint_lt(x, x);
470 }
471 END_TEST
472
473 START_TEST(test_ck_assert_uint_lt_with_mod)
474 {
475   int d = 2;
476   int f = 1;
477
478   record_test_name(tcase_name());
479
480   record_failure_line_num(__LINE__);
481   ck_assert_uint_lt(3%d, 1%f);
482 }
483 END_TEST
484
485 START_TEST(test_ck_assert_uint_le)
486 {
487   unsigned int x = 2;
488   unsigned int y = 3;
489
490   record_test_name(tcase_name());
491
492   ck_assert_uint_le(x, y);
493   ck_assert_uint_le(x, x);
494   record_failure_line_num(__LINE__);
495   ck_assert_uint_le(y, x);
496 }
497 END_TEST
498
499 START_TEST(test_ck_assert_uint_le_with_mod)
500 {
501   int d = 2;
502   int f = 1;
503
504   record_test_name(tcase_name());
505
506   record_failure_line_num(__LINE__);
507   ck_assert_uint_le(3%d, 1%f);
508 }
509 END_TEST
510
511 START_TEST(test_ck_assert_uint_gt)
512 {
513   unsigned int x = 2;
514   unsigned int y = 3;
515
516   record_test_name(tcase_name());
517
518   ck_assert_uint_gt(y, x);
519   record_failure_line_num(__LINE__);
520   ck_assert_uint_gt(y, y);
521 }
522 END_TEST
523
524 START_TEST(test_ck_assert_uint_gt_with_mod)
525 {
526   int d = 1;
527   int f = 2;
528
529   record_test_name(tcase_name());
530
531   record_failure_line_num(__LINE__);
532   ck_assert_uint_gt(1%d, 3%f);
533 }
534 END_TEST
535
536 START_TEST(test_ck_assert_uint_ge)
537 {
538   unsigned int x = 2;
539   unsigned int y = 3;
540
541   record_test_name(tcase_name());
542
543   ck_assert_uint_ge(y, x);
544   ck_assert_uint_ge(y, x);
545   record_failure_line_num(__LINE__);
546   ck_assert_uint_ge(x, y);
547 }
548 END_TEST
549
550 START_TEST(test_ck_assert_uint_ge_with_mod)
551 {
552   int d = 1;
553   int f = 2;
554
555   record_test_name(tcase_name());
556
557   record_failure_line_num(__LINE__);
558   ck_assert_uint_ge(1%d, 3%f);
559 }
560 END_TEST
561
562 START_TEST(test_ck_assert_uint_expr)
563 {
564   unsigned int x = 1;
565   unsigned int y = 0;
566
567   record_test_name(tcase_name());
568
569   ck_assert_uint_eq(x, ++y);
570   ck_assert_uint_eq(x, y);
571 } END_TEST
572
573 START_TEST(test_ck_assert_float_eq)
574 {
575   float x = 1.1f;
576   float y = 1.1f;
577
578   record_test_name(tcase_name());
579
580   ck_assert_float_eq(x, y);
581   y+=0.1f;
582   record_failure_line_num(__LINE__);
583   ck_assert_float_eq(x, y);
584 }
585 END_TEST
586
587 START_TEST(test_ck_assert_float_eq_with_mod)
588 {
589   int d = 2;
590   int f = 2;
591
592   record_test_name(tcase_name());
593
594   record_failure_line_num(__LINE__);
595   ck_assert_float_eq(3%d, 2%f);
596 }
597 END_TEST
598
599 START_TEST(test_ck_assert_float_ne)
600 {
601   float x = 1.1f;
602   float y = 1.2f;
603
604   record_test_name(tcase_name());
605
606   ck_assert_float_ne(x, y);
607   y = x;
608   record_failure_line_num(__LINE__);
609   ck_assert_float_ne(x, y);
610 }
611 END_TEST
612
613 START_TEST(test_ck_assert_float_ne_with_mod)
614 {
615   int d = 2;
616   int f = 2;
617
618   record_test_name(tcase_name());
619
620   record_failure_line_num(__LINE__);
621   ck_assert_float_ne(1%d, 1%f);
622 }
623 END_TEST
624
625 START_TEST(test_ck_assert_float_lt)
626 {
627   float x = 2.0f;
628   float y = 2.5f;
629
630   record_test_name(tcase_name());
631
632   ck_assert_float_lt(x, y);
633   y-=1.0f;
634   record_failure_line_num(__LINE__);
635   ck_assert_float_lt(x, y);
636 }
637 END_TEST
638
639 START_TEST(test_ck_assert_float_lt_with_mod)
640 {
641   int d = 2;
642   int f = 2;
643
644   record_test_name(tcase_name());
645
646   record_failure_line_num(__LINE__);
647   ck_assert_float_lt(3%d, 2%f);
648 }
649 END_TEST
650
651 START_TEST(test_ck_assert_float_le)
652 {
653   float x = 2.0f;
654   float y = 2.5f;
655
656   record_test_name(tcase_name());
657
658   ck_assert_float_le(x, y);
659   ck_assert_float_le(x, x);
660   y-=1.0f;
661   record_failure_line_num(__LINE__);
662   ck_assert_float_le(x, y);
663 }
664 END_TEST
665
666 START_TEST(test_ck_assert_float_le_with_mod)
667 {
668   int d = 2;
669   int f = 2;
670
671   record_test_name(tcase_name());
672
673   record_failure_line_num(__LINE__);
674   ck_assert_float_le(3%d, 2%f);
675 }
676 END_TEST
677
678 START_TEST(test_ck_assert_float_gt)
679 {
680   float x = 2.5f;
681   float y = 2.0f;
682
683   record_test_name(tcase_name());
684
685   ck_assert_float_gt(x, y);
686   y+=1.0f;
687   record_failure_line_num(__LINE__);
688   ck_assert_float_gt(x, y);
689 }
690 END_TEST
691
692 START_TEST(test_ck_assert_float_gt_with_mod)
693 {
694   int d = 2;
695   int f = 2;
696
697   record_test_name(tcase_name());
698
699   record_failure_line_num(__LINE__);
700   ck_assert_float_gt(2%d, 3%f);
701 }
702 END_TEST
703
704 START_TEST(test_ck_assert_float_ge)
705 {
706   float x = 2.5f;
707   float y = 2.0f;
708
709   record_test_name(tcase_name());
710
711   ck_assert_float_ge(x, y);
712   ck_assert_float_ge(x, x);
713   y+=1.0f;
714   record_failure_line_num(__LINE__);
715   ck_assert_float_ge(x, y);
716 }
717 END_TEST
718
719 START_TEST(test_ck_assert_float_ge_with_mod)
720 {
721   int d = 2;
722   int f = 2;
723
724   record_test_name(tcase_name());
725
726   record_failure_line_num(__LINE__);
727   ck_assert_float_ge(2%d, 3%f);
728 }
729 END_TEST
730
731 START_TEST(test_ck_assert_float_with_expr)
732 {
733   float x[] = {NAN, 1.1f, 1.1f, 1.2f, 1.2f, NAN};
734   float y = 1.1f;
735   int i;
736
737   record_test_name(tcase_name());
738
739   i = 1;
740   ck_assert_float_eq(x[i++], y);
741   ck_assert_float_eq(x[i++], y);
742
743   i = 4;
744   ck_assert_float_ne(x[i--], y);
745   ck_assert_float_ne(x[i--], y);
746
747   y = 1.15f;
748
749   i = 1;
750   ck_assert_float_le(x[i++], y);
751   ck_assert_float_le(x[i++], y);
752
753   i = 1;
754   ck_assert_float_lt(x[i++], y);
755   ck_assert_float_lt(x[i++], y);
756
757   i = 4;
758   ck_assert_float_gt(x[i--], y);
759   ck_assert_float_gt(x[i--], y);
760
761   i = 4;
762   ck_assert_float_ge(x[i--], y);
763   ck_assert_float_ge(x[i--], y);
764 }
765 END_TEST
766
767 START_TEST(test_ck_assert_float_eq_tol)
768 {
769   float x = 0.0001f;
770   float y = 0.0003f;
771   float t = 0.001f;
772
773   record_test_name(tcase_name());
774
775   ck_assert_float_eq_tol(x, y, t);
776   ck_assert_float_eq_tol(x, x, t);
777   x*=10.0f;
778   y*=10.0f;
779   t*=10.0f;
780   ck_assert_float_eq_tol(x, y, t);
781   t/=10.0f;
782   record_failure_line_num(__LINE__);
783   ck_assert_float_eq_tol(x, y, t);
784 }
785 END_TEST
786
787 START_TEST(test_ck_assert_float_eq_tol_with_mod)
788 {
789   int d = 2;
790   int f = 2;
791   int p = 2;
792
793   record_test_name(tcase_name());
794
795   record_failure_line_num(__LINE__);
796   ck_assert_float_eq_tol(3%d, 2%f, 2%p);
797 }
798 END_TEST
799
800 START_TEST(test_ck_assert_float_ne_tol)
801 {
802   float x = 0.0001f;
803   float y = 0.0002f;
804   float t = 0.0001f;
805
806   record_test_name(tcase_name());
807
808   ck_assert_float_ne_tol(x, y, t);
809   x*=10.0f;
810   y*=10.0f;
811   t*=10.0f;
812   ck_assert_float_ne_tol(x, y, t);
813   t*=10.0f;
814   record_failure_line_num(__LINE__);
815   ck_assert_float_ne_tol(x, y, t);
816 }
817 END_TEST
818
819 START_TEST(test_ck_assert_float_ne_tol_with_mod)
820 {
821   int d = 2;
822   int f = 2;
823   int p = 2;
824
825   record_test_name(tcase_name());
826
827   record_failure_line_num(__LINE__);
828   ck_assert_float_ne_tol(3%d, 3%f, 3%p);
829 }
830 END_TEST
831
832 START_TEST(test_ck_assert_float_ge_tol)
833 {
834   float x = 0.001f;
835   float y = 0.003f;
836   float t = 0.001f;
837
838   record_test_name(tcase_name());
839
840   ck_assert_float_ge_tol(y, x, t);
841   ck_assert_float_ge_tol(x, x, t);
842   ck_assert_float_ge_tol(y, y, t);
843   x*=10.0f;
844   y*=10.0f;
845   t*=10.0f;
846   ck_assert_float_ge_tol(y, x, t);
847   ck_assert_float_ge_tol(x, x, t);
848   ck_assert_float_ge_tol(y, y, t);
849   record_failure_line_num(__LINE__);
850   ck_assert_float_ge_tol(x, y, t);
851 }
852 END_TEST
853
854 START_TEST(test_ck_assert_float_ge_tol_with_mod)
855 {
856   int d = 2;
857   int f = 2;
858   int p = 2;
859
860   record_test_name(tcase_name());
861
862   record_failure_line_num(__LINE__);
863   ck_assert_float_ge_tol(2%d, 3%f, 3%p);
864 }
865 END_TEST
866
867 START_TEST(test_ck_assert_float_le_tol)
868 {
869   float x = 0.001f;
870   float y = 0.003f;
871   float t = 0.001f;
872
873   record_test_name(tcase_name());
874
875   ck_assert_float_le_tol(x, y, t);
876   ck_assert_float_le_tol(x, x, t);
877   ck_assert_float_le_tol(y, y, t);
878   x*=10.0f;
879   y*=10.0f;
880   t*=10.0f;
881   ck_assert_float_le_tol(x, y, t);
882   ck_assert_float_le_tol(x, x, t);
883   ck_assert_float_le_tol(y, y, t);
884   record_failure_line_num(__LINE__);
885   ck_assert_float_le_tol(y, x, t);
886 }
887 END_TEST
888
889 START_TEST(test_ck_assert_float_le_tol_with_mod)
890 {
891   int d = 2;
892   int f = 2;
893   int p = 2;
894
895   record_test_name(tcase_name());
896
897   record_failure_line_num(__LINE__);
898   ck_assert_float_le_tol(3%d, 2%f, 3%p);
899 }
900 END_TEST
901
902 START_TEST(test_ck_assert_float_tol_with_expr)
903 {
904   float x[] = {NAN, 1.1f, 1.1f, 1.2f, 1.2f, NAN};
905   float y = 1.1f;
906   float t = 0.01f;
907   int i;
908
909   record_test_name(tcase_name());
910
911   i = 1;
912   ck_assert_float_eq_tol(x[i++], y, t);
913   ck_assert_float_eq_tol(x[i++], y, t);
914
915   i = 4;
916   ck_assert_float_ne_tol(x[i--], y, t);
917   ck_assert_float_ne_tol(x[i--], y, t);
918
919   y = 1.15f;
920
921   i = 1;
922   ck_assert_float_le_tol(x[i++], y, t);
923   ck_assert_float_le_tol(x[i++], y, t);
924
925   i = 4;
926   ck_assert_float_ge_tol(x[i--], y, t);
927   ck_assert_float_ge_tol(x[i--], y, t);
928 }
929 END_TEST
930
931 START_TEST(test_ck_assert_float_finite)
932 {
933   float x = 0.0001f;
934   float t = 1.0f;
935
936   record_test_name(tcase_name());
937
938   ck_assert_float_finite(x);
939   /* MS VS doesn't allow explicit division by zero */
940   x = 1.0f / (1.0f - t);
941   record_failure_line_num(__LINE__);
942   ck_assert_float_finite(x);
943 }
944 END_TEST
945
946 START_TEST(test_ck_assert_float_finite_with_mod)
947 {
948   int d = 2;
949   float t = 1.0f;
950   float x = 1.0f / (1.0f - t);
951
952   record_test_name(tcase_name());
953
954   record_failure_line_num(__LINE__);
955   ck_assert_float_finite(x*(1%d));
956 }
957 END_TEST
958
959 START_TEST(test_ck_assert_float_infinite)
960 {
961   float t = 1.0f;
962   float x = 1.0f / (1.0f - t);
963
964   record_test_name(tcase_name());
965
966   ck_assert_float_infinite(x);
967   x = -1.0f / (1.0f - t);
968   ck_assert_float_infinite(x);
969   x = 0.0f;
970   record_failure_line_num(__LINE__);
971   ck_assert_float_infinite(x);
972 }
973 END_TEST
974
975 START_TEST(test_ck_assert_float_infinite_with_mod)
976 {
977   int d = 2;
978
979   record_test_name(tcase_name());
980
981   record_failure_line_num(__LINE__);
982   ck_assert_float_infinite(2%d);
983 }
984 END_TEST
985
986 START_TEST(test_ck_assert_float_nan)
987 {
988   float t = 1.0f;
989   float x = 0.0f / (1.0f - t);
990
991   record_test_name(tcase_name());
992
993   ck_assert_float_nan(x);
994   x = 1.0f / (1.0f - t);
995   record_failure_line_num(__LINE__);
996   ck_assert_float_nan(x);
997 }
998 END_TEST
999
1000 START_TEST(test_ck_assert_float_nan_with_mod)
1001 {
1002   int d = 2;
1003
1004   record_test_name(tcase_name());
1005
1006   record_failure_line_num(__LINE__);
1007   ck_assert_float_nan(2%d);
1008 }
1009 END_TEST
1010
1011 START_TEST(test_ck_assert_float_nonnan)
1012 {
1013   float x = 0.0f;
1014   float t = 1.0f;
1015
1016   record_test_name(tcase_name());
1017
1018   ck_assert_float_nonnan(x);
1019 #if ENABLE_REGEX
1020   x = 0.0f / (1.0f - t);
1021   record_failure_line_num(__LINE__);
1022   ck_assert_float_nonnan(x);
1023 #else
1024   (void)t; /* unused */
1025 #endif
1026 }
1027 END_TEST
1028
1029 START_TEST(test_ck_assert_float_nonnan_with_mod)
1030 {
1031   int s = 2;
1032   float t = 1.0f;
1033   float x;
1034
1035   record_test_name(tcase_name());
1036
1037   ck_assert_float_nonnan(2%s);
1038 #if ENABLE_REGEX
1039   x = 0.0f / (1.0f - t);
1040   record_failure_line_num(__LINE__);
1041   ck_assert_float_nonnan((2%s)*x);
1042 #else
1043   (void)x; /* unused */
1044   (void)t; /* unused */
1045 #endif
1046 }
1047 END_TEST
1048
1049 START_TEST(test_ck_assert_float_nan_and_inf_with_expr)
1050 {
1051   float x[] = {0.0f, 0.0f, INFINITY, INFINITY, NAN, NAN, 0.0f, 0.0f, NAN};
1052   int i = 0;
1053
1054   record_test_name(tcase_name());
1055
1056   ck_assert_float_finite(x[i++]);
1057   ck_assert_float_finite(x[i++]);
1058   ck_assert_float_infinite(x[i++]);
1059   ck_assert_float_infinite(x[i++]);
1060   ck_assert_float_nan(x[i++]);
1061   ck_assert_float_nan(x[i++]);
1062   ck_assert_float_nonnan(x[i++]);
1063   ck_assert_float_nonnan(x[i++]);
1064 }
1065 END_TEST
1066
1067 START_TEST(test_ck_assert_double_eq)
1068 {
1069   double x = 1.1;
1070   double y = 1.1;
1071
1072   record_test_name(tcase_name());
1073
1074   ck_assert_double_eq(x, y);
1075   y+=0.1;
1076   record_failure_line_num(__LINE__);
1077   ck_assert_double_eq(x, y);
1078 }
1079 END_TEST
1080
1081 START_TEST(test_ck_assert_double_eq_with_mod)
1082 {
1083   int d = 2;
1084   int f = 2;
1085
1086   record_test_name(tcase_name());
1087
1088   record_failure_line_num(__LINE__);
1089   ck_assert_double_eq(3%d, 2%f);
1090 }
1091 END_TEST
1092
1093 START_TEST(test_ck_assert_double_eq_with_promotion)
1094 {
1095   float x = 0.1;
1096   double y = x;
1097
1098   record_test_name(tcase_name());
1099
1100   ck_assert_double_eq(x, y);
1101 }
1102 END_TEST
1103
1104 START_TEST(test_ck_assert_double_eq_with_conv)
1105 {
1106   float x = 0.1;
1107
1108   record_test_name(tcase_name());
1109
1110   record_failure_line_num(__LINE__);
1111   ck_assert_double_eq(x, 0.1);
1112 }
1113 END_TEST
1114
1115 START_TEST(test_ck_assert_double_ne)
1116 {
1117   double x = 1.1;
1118   double y = 1.2;
1119
1120   record_test_name(tcase_name());
1121
1122   ck_assert_double_ne(x, y);
1123   y = x;
1124   record_failure_line_num(__LINE__);
1125   ck_assert_double_ne(x, y);
1126 }
1127 END_TEST
1128
1129 START_TEST(test_ck_assert_double_ne_with_mod)
1130 {
1131   int d = 2;
1132   int f = 2;
1133
1134   record_test_name(tcase_name());
1135
1136   record_failure_line_num(__LINE__);
1137   ck_assert_double_ne(1%d, 1%f);
1138 }
1139 END_TEST
1140
1141 START_TEST(test_ck_assert_double_lt)
1142 {
1143   double x = 2.0;
1144   double y = 2.5;
1145
1146   record_test_name(tcase_name());
1147
1148   ck_assert_double_lt(x, y);
1149   y-=1;
1150   record_failure_line_num(__LINE__);
1151   ck_assert_double_lt(x, y);
1152 }
1153 END_TEST
1154
1155 START_TEST(test_ck_assert_double_lt_with_mod)
1156 {
1157   int d = 2;
1158   int f = 2;
1159
1160   record_test_name(tcase_name());
1161
1162   record_failure_line_num(__LINE__);
1163   ck_assert_double_lt(3%d, 2%f);
1164 }
1165 END_TEST
1166
1167 START_TEST(test_ck_assert_double_le)
1168 {
1169   double x = 2.0;
1170   double y = 2.5;
1171
1172   record_test_name(tcase_name());
1173
1174   ck_assert_double_le(x, y);
1175   ck_assert_double_le(x, x);
1176   y-=1;
1177   record_failure_line_num(__LINE__);
1178   ck_assert_double_le(x, y);
1179 }
1180 END_TEST
1181
1182 START_TEST(test_ck_assert_double_le_with_mod)
1183 {
1184   int d = 2;
1185   int f = 2;
1186
1187   record_test_name(tcase_name());
1188
1189   record_failure_line_num(__LINE__);
1190   ck_assert_double_le(3%d, 2%f);
1191 }
1192 END_TEST
1193
1194 START_TEST(test_ck_assert_double_gt)
1195 {
1196   double x = 2.5;
1197   double y = 2.0;
1198
1199   record_test_name(tcase_name());
1200
1201   ck_assert_double_gt(x, y);
1202   y+=1;
1203   record_failure_line_num(__LINE__);
1204   ck_assert_double_gt(x, y);
1205 }
1206 END_TEST
1207
1208 START_TEST(test_ck_assert_double_gt_with_mod)
1209 {
1210   int d = 2;
1211   int f = 2;
1212
1213   record_test_name(tcase_name());
1214
1215   record_failure_line_num(__LINE__);
1216   ck_assert_double_gt(2%d, 3%f);
1217 }
1218 END_TEST
1219
1220 START_TEST(test_ck_assert_double_ge)
1221 {
1222   double x = 2.5;
1223   double y = 2.0;
1224
1225   record_test_name(tcase_name());
1226
1227   ck_assert_double_ge(x, y);
1228   ck_assert_double_ge(x, x);
1229   y+=1;
1230   record_failure_line_num(__LINE__);
1231   ck_assert_double_ge(x, y);
1232 }
1233 END_TEST
1234
1235 START_TEST(test_ck_assert_double_ge_with_mod)
1236 {
1237   int d = 2;
1238   int f = 2;
1239
1240   record_test_name(tcase_name());
1241
1242   record_failure_line_num(__LINE__);
1243   ck_assert_double_ge(2%d, 3%f);
1244 }
1245 END_TEST
1246
1247 START_TEST(test_ck_assert_double_with_expr)
1248 {
1249   double x[] = {NAN, 1.1, 1.1, 1.2, 1.2, NAN};
1250   double y = 1.1;
1251   int i;
1252
1253   record_test_name(tcase_name());
1254
1255   i = 1;
1256   ck_assert_double_eq(x[i++], y);
1257   ck_assert_double_eq(x[i++], y);
1258
1259   i = 4;
1260   ck_assert_double_ne(x[i--], y);
1261   ck_assert_double_ne(x[i--], y);
1262
1263   y = 1.15;
1264
1265   i = 1;
1266   ck_assert_double_le(x[i++], y);
1267   ck_assert_double_le(x[i++], y);
1268
1269   i = 1;
1270   ck_assert_double_lt(x[i++], y);
1271   ck_assert_double_lt(x[i++], y);
1272
1273   i = 4;
1274   ck_assert_double_gt(x[i--], y);
1275   ck_assert_double_gt(x[i--], y);
1276
1277   i = 4;
1278   ck_assert_double_ge(x[i--], y);
1279   ck_assert_double_ge(x[i--], y);
1280 }
1281 END_TEST
1282
1283 START_TEST(test_ck_assert_double_eq_tol)
1284 {
1285   double x = 0.0001;
1286   double y = 0.0002;
1287   double t = 0.001;
1288
1289   record_test_name(tcase_name());
1290
1291   ck_assert_double_eq_tol(x, y, t);
1292   ck_assert_double_eq_tol(x, x, t);
1293   x*=10;
1294   y*=10;
1295   t*=10;
1296   ck_assert_double_eq_tol(x, y, t);
1297   t/=10;
1298   record_failure_line_num(__LINE__);
1299   ck_assert_double_eq_tol(x, y, t);
1300 }
1301 END_TEST
1302
1303 START_TEST(test_ck_assert_double_eq_tol_with_mod)
1304 {
1305   int d = 2;
1306   int f = 2;
1307   int p = 2;
1308
1309   record_test_name(tcase_name());
1310
1311   record_failure_line_num(__LINE__);
1312   ck_assert_double_eq_tol(3%d, 2%f, 2%p);
1313 }
1314 END_TEST
1315
1316 START_TEST(test_ck_assert_double_ne_tol)
1317 {
1318   double x = 0.0001;
1319   double y = 0.0002;
1320   double t = 0.0001;
1321
1322   record_test_name(tcase_name());
1323
1324   ck_assert_double_ne_tol(x, y, t);
1325   x*=10;
1326   y*=10;
1327   t*=10;
1328   ck_assert_double_ne_tol(x, y, t);
1329   t*=10;
1330   record_failure_line_num(__LINE__);
1331   ck_assert_double_ne_tol(x, y, t);
1332 }
1333 END_TEST
1334
1335 START_TEST(test_ck_assert_double_ne_tol_with_mod)
1336 {
1337   int d = 2;
1338   int f = 2;
1339   int p = 2;
1340
1341   record_test_name(tcase_name());
1342
1343   record_failure_line_num(__LINE__);
1344   ck_assert_double_ne_tol(3%d, 3%f, 3%p);
1345 }
1346 END_TEST
1347
1348 START_TEST(test_ck_assert_double_ge_tol)
1349 {
1350   double x = 0.001;
1351   double y = 0.003;
1352   double t = 0.001;
1353
1354   record_test_name(tcase_name());
1355
1356   ck_assert_double_ge_tol(y, x, t);
1357   ck_assert_double_ge_tol(x, x, t);
1358   ck_assert_double_ge_tol(y, y, t);
1359   x*=10.0;
1360   y*=10.0;
1361   t*=10.0;
1362   ck_assert_double_ge_tol(y, x, t);
1363   ck_assert_double_ge_tol(x, x, t);
1364   ck_assert_double_ge_tol(y, y, t);
1365   record_failure_line_num(__LINE__);
1366   ck_assert_double_ge_tol(x, y, t);
1367 }
1368 END_TEST
1369
1370 START_TEST(test_ck_assert_double_ge_tol_with_mod)
1371 {
1372   int d = 2;
1373   int f = 2;
1374   int p = 2;
1375
1376   record_test_name(tcase_name());
1377
1378   record_failure_line_num(__LINE__);
1379   ck_assert_double_ge_tol(2%d, 3%f, 3%p);
1380 }
1381 END_TEST
1382
1383 START_TEST(test_ck_assert_double_le_tol)
1384 {
1385   double x = 0.001;
1386   double y = 0.003;
1387   double t = 0.001;
1388
1389   record_test_name(tcase_name());
1390
1391   ck_assert_double_le_tol(x, y, t);
1392   ck_assert_double_le_tol(x, x, t);
1393   ck_assert_double_le_tol(y, y, t);
1394   x*=10.0;
1395   y*=10.0;
1396   t*=10.0;
1397   ck_assert_double_le_tol(x, y, t);
1398   ck_assert_double_le_tol(x, x, t);
1399   ck_assert_double_le_tol(y, y, t);
1400   record_failure_line_num(__LINE__);
1401   ck_assert_double_le_tol(y, x, t);
1402 }
1403 END_TEST
1404
1405 START_TEST(test_ck_assert_double_le_tol_with_mod)
1406 {
1407   int d = 2;
1408   int f = 2;
1409   int p = 2;
1410
1411   record_test_name(tcase_name());
1412
1413   record_failure_line_num(__LINE__);
1414   ck_assert_double_le_tol(3%d, 2%f, 3%p);
1415 }
1416 END_TEST
1417
1418 START_TEST(test_ck_assert_double_tol_with_expr)
1419 {
1420   double x[] = {NAN, 1.1, 1.1, 1.2, 1.2, NAN};
1421   double y = 1.1;
1422   double t = 0.01;
1423   int i;
1424
1425   record_test_name(tcase_name());
1426
1427   i = 1;
1428   ck_assert_double_eq_tol(x[i++], y, t);
1429   ck_assert_double_eq_tol(x[i++], y, t);
1430
1431   i = 4;
1432   ck_assert_double_ne_tol(x[i--], y, t);
1433   ck_assert_double_ne_tol(x[i--], y, t);
1434
1435   y = 1.15;
1436
1437   i = 1;
1438   ck_assert_double_le_tol(x[i++], y, t);
1439   ck_assert_double_le_tol(x[i++], y, t);
1440
1441   i = 4;
1442   ck_assert_double_ge_tol(x[i--], y, t);
1443   ck_assert_double_ge_tol(x[i--], y, t);
1444 }
1445 END_TEST
1446
1447 START_TEST(test_ck_assert_double_finite)
1448 {
1449   double x = 0.0001;
1450   double t = 1;
1451
1452   record_test_name(tcase_name());
1453
1454   ck_assert_double_finite(x);
1455   /* MS VS doesn't allow explicit division by zero */
1456   x = 1.0 / (1.0 - t);
1457   record_failure_line_num(__LINE__);
1458   ck_assert_double_finite(x);
1459 }
1460 END_TEST
1461
1462 START_TEST(test_ck_assert_double_finite_with_mod)
1463 {
1464   int d = 2;
1465   double t = 1;
1466   double x = 1.0 / (1.0 - t);
1467
1468   record_test_name(tcase_name());
1469
1470   record_failure_line_num(__LINE__);
1471   ck_assert_double_finite(x*(1%d));
1472 }
1473 END_TEST
1474
1475 START_TEST(test_ck_assert_double_infinite)
1476 {
1477   double t = 1;
1478   double x = 1.0 / (1.0 - t);
1479
1480   record_test_name(tcase_name());
1481
1482   ck_assert_double_infinite(x);
1483   x = -1.0 / (1.0 - t);
1484   ck_assert_double_infinite(x);
1485   x = 0;
1486   record_failure_line_num(__LINE__);
1487   ck_assert_double_infinite(x);
1488 }
1489 END_TEST
1490
1491 START_TEST(test_ck_assert_double_infinite_with_mod)
1492 {
1493   int d = 2;
1494
1495   record_test_name(tcase_name());
1496
1497   record_failure_line_num(__LINE__);
1498   ck_assert_double_infinite(2%d);
1499 }
1500 END_TEST
1501
1502 START_TEST(test_ck_assert_double_nan)
1503 {
1504   double t = 1;
1505   double x = 0.0 / (1.0 - t);
1506
1507   record_test_name(tcase_name());
1508
1509   ck_assert_double_nan(x);
1510   x = 1.0 / (1.0 - t);
1511   record_failure_line_num(__LINE__);
1512   ck_assert_double_nan(x);
1513 }
1514 END_TEST
1515
1516 START_TEST(test_ck_assert_double_nan_with_mod)
1517 {
1518   int d = 2;
1519
1520   record_test_name(tcase_name());
1521
1522   record_failure_line_num(__LINE__);
1523   ck_assert_double_nan(2%d);
1524 }
1525 END_TEST
1526
1527 START_TEST(test_ck_assert_double_nonnan)
1528 {
1529   double x = 0;
1530   double t = 1;
1531
1532   record_test_name(tcase_name());
1533
1534   ck_assert_double_nonnan(x);
1535 #if ENABLE_REGEX
1536   x = 0.0 / (1.0 - t);
1537   record_failure_line_num(__LINE__);
1538   ck_assert_double_nonnan(x);
1539 #else
1540   (void)t; /* unused */
1541 #endif
1542 }
1543 END_TEST
1544
1545 START_TEST(test_ck_assert_double_nonnan_with_mod)
1546 {
1547   int s = 2;
1548   double t = 1.0;
1549   double x;
1550
1551   record_test_name(tcase_name());
1552
1553   ck_assert_double_nonnan(2%s);
1554 #if ENABLE_REGEX
1555   x = 0.0 / (1.0 - t);
1556   record_failure_line_num(__LINE__);
1557   ck_assert_double_nonnan((2%s)*x);
1558 #else
1559   (void)t; /* unused */
1560   (void)x; /* unused */
1561 #endif
1562 }
1563 END_TEST
1564
1565 START_TEST(test_ck_assert_double_nan_and_inf_with_expr)
1566 {
1567   double x[] = {0.0, 0.0, INFINITY, INFINITY, NAN, NAN, 0.0, 0.0, NAN};
1568   int i = 0;
1569
1570   record_test_name(tcase_name());
1571
1572   ck_assert_double_finite(x[i++]);
1573   ck_assert_double_finite(x[i++]);
1574   ck_assert_double_infinite(x[i++]);
1575   ck_assert_double_infinite(x[i++]);
1576   ck_assert_double_nan(x[i++]);
1577   ck_assert_double_nan(x[i++]);
1578   ck_assert_double_nonnan(x[i++]);
1579   ck_assert_double_nonnan(x[i++]);
1580 }
1581 END_TEST
1582
1583 START_TEST(test_ck_assert_ldouble_eq)
1584 {
1585   long double x = 1.1l;
1586   long double y = 1.1l;
1587
1588   record_test_name(tcase_name());
1589
1590   ck_assert_ldouble_eq(x, y);
1591   y+=0.1l;
1592   record_failure_line_num(__LINE__);
1593   ck_assert_ldouble_eq(x, y);
1594 }
1595 END_TEST
1596
1597 START_TEST(test_ck_assert_ldouble_eq_with_mod)
1598 {
1599   int d = 2;
1600   int f = 2;
1601
1602   record_test_name(tcase_name());
1603
1604   record_failure_line_num(__LINE__);
1605   ck_assert_ldouble_eq(3%d, 2%f);
1606 }
1607 END_TEST
1608
1609 START_TEST(test_ck_assert_ldouble_eq_with_promotion)
1610 {
1611   float x = 1.1;
1612   long double y = x;
1613
1614   record_test_name(tcase_name());
1615
1616   ck_assert_ldouble_eq(x, y);
1617 }
1618 END_TEST
1619
1620 START_TEST(test_ck_assert_ldouble_eq_with_conv)
1621 {
1622   float x = 1.1;
1623   long double y = x;
1624
1625   record_test_name(tcase_name());
1626
1627   ck_assert_ldouble_eq(x, y);
1628   record_failure_line_num(__LINE__);
1629   ck_assert_ldouble_eq(x, 1.1);
1630 }
1631 END_TEST
1632
1633 START_TEST(test_ck_assert_ldouble_ne)
1634 {
1635   long double x = 1.1l;
1636   long double y = 1.2l;
1637
1638   record_test_name(tcase_name());
1639
1640   ck_assert_ldouble_ne(x, y);
1641   y = x;
1642   record_failure_line_num(__LINE__);
1643   ck_assert_ldouble_ne(x, y);
1644 }
1645 END_TEST
1646
1647 START_TEST(test_ck_assert_ldouble_ne_with_mod)
1648 {
1649   int d = 2;
1650   int f = 2;
1651
1652   record_test_name(tcase_name());
1653
1654   record_failure_line_num(__LINE__);
1655   ck_assert_ldouble_ne(1%d, 1%f);
1656 }
1657 END_TEST
1658
1659 START_TEST(test_ck_assert_ldouble_lt)
1660 {
1661   long double x = 2.0l;
1662   long double y = 2.5l;
1663
1664   record_test_name(tcase_name());
1665
1666   ck_assert_ldouble_lt(x, y);
1667   y-=1.0l;
1668   record_failure_line_num(__LINE__);
1669   ck_assert_ldouble_lt(x, y);
1670 }
1671 END_TEST
1672
1673 START_TEST(test_ck_assert_ldouble_lt_with_mod)
1674 {
1675   int d = 2;
1676   int f = 2;
1677
1678   record_test_name(tcase_name());
1679
1680   record_failure_line_num(__LINE__);
1681   ck_assert_ldouble_lt(3%d, 2%f);
1682 }
1683 END_TEST
1684
1685 START_TEST(test_ck_assert_ldouble_le)
1686 {
1687   long double x = 2.0l;
1688   long double y = 2.5l;
1689
1690   record_test_name(tcase_name());
1691
1692   ck_assert_ldouble_le(x, y);
1693   ck_assert_ldouble_le(x, x);
1694   y-=1.0l;
1695   record_failure_line_num(__LINE__);
1696   ck_assert_ldouble_le(x, y);
1697 }
1698 END_TEST
1699
1700 START_TEST(test_ck_assert_ldouble_le_with_mod)
1701 {
1702   int d = 2;
1703   int f = 2;
1704
1705   record_test_name(tcase_name());
1706
1707   record_failure_line_num(__LINE__);
1708   ck_assert_ldouble_le(3%d, 2%f);
1709 }
1710 END_TEST
1711
1712 START_TEST(test_ck_assert_ldouble_gt)
1713 {
1714   long double x = 2.5l;
1715   long double y = 2.0l;
1716
1717   record_test_name(tcase_name());
1718
1719   ck_assert_ldouble_gt(x, y);
1720   y+=1.0l;
1721   record_failure_line_num(__LINE__);
1722   ck_assert_ldouble_gt(x, y);
1723 }
1724 END_TEST
1725
1726 START_TEST(test_ck_assert_ldouble_gt_with_mod)
1727 {
1728   int d = 2;
1729   int f = 2;
1730
1731   record_test_name(tcase_name());
1732
1733   record_failure_line_num(__LINE__);
1734   ck_assert_ldouble_gt(2%d, 3%f);
1735 }
1736 END_TEST
1737
1738 START_TEST(test_ck_assert_ldouble_ge)
1739 {
1740   long double x = 2.5l;
1741   long double y = 2.0l;
1742
1743   record_test_name(tcase_name());
1744
1745   ck_assert_ldouble_ge(x, y);
1746   ck_assert_ldouble_ge(x, x);
1747   y+=1.0l;
1748   record_failure_line_num(__LINE__);
1749   ck_assert_ldouble_ge(x, y);
1750 }
1751 END_TEST
1752
1753 START_TEST(test_ck_assert_ldouble_ge_with_mod)
1754 {
1755   int d = 2;
1756   int f = 2;
1757
1758   record_test_name(tcase_name());
1759
1760   record_failure_line_num(__LINE__);
1761   ck_assert_ldouble_ge(2%d, 3%f);
1762 }
1763 END_TEST
1764
1765 START_TEST(test_ck_assert_ldouble_with_expr)
1766 {
1767   long double x[] = {NAN, 1.1l, 1.1l, 1.2l, 1.2l, NAN};
1768   long double y = 1.1l;
1769   int i;
1770
1771   record_test_name(tcase_name());
1772
1773   i = 1;
1774   ck_assert_ldouble_eq(x[i++], y);
1775   ck_assert_ldouble_eq(x[i++], y);
1776
1777   i = 4;
1778   ck_assert_ldouble_ne(x[i--], y);
1779   ck_assert_ldouble_ne(x[i--], y);
1780
1781   y = 1.15l;
1782
1783   i = 1;
1784   ck_assert_ldouble_le(x[i++], y);
1785   ck_assert_ldouble_le(x[i++], y);
1786
1787   i = 1;
1788   ck_assert_ldouble_lt(x[i++], y);
1789   ck_assert_ldouble_lt(x[i++], y);
1790
1791   i = 4;
1792   ck_assert_ldouble_gt(x[i--], y);
1793   ck_assert_ldouble_gt(x[i--], y);
1794
1795   i = 4;
1796   ck_assert_ldouble_ge(x[i--], y);
1797   ck_assert_ldouble_ge(x[i--], y);
1798 }
1799 END_TEST
1800
1801 START_TEST(test_ck_assert_ldouble_eq_tol)
1802 {
1803   long double x = 0.0001l;
1804   long double y = 0.0002l;
1805   long double t = 0.001l;
1806
1807   record_test_name(tcase_name());
1808
1809   ck_assert_ldouble_eq_tol(x, y, t);
1810   ck_assert_ldouble_eq_tol(x, x, t);
1811   x*=10.0l;
1812   y*=10.0l;
1813   t*=10.0l;
1814   ck_assert_ldouble_eq_tol(x, y, t);
1815   t/=10.0l;
1816   record_failure_line_num(__LINE__);
1817   ck_assert_ldouble_eq_tol(x, y, t);
1818 }
1819 END_TEST
1820
1821 START_TEST(test_ck_assert_ldouble_eq_tol_with_mod)
1822 {
1823   int d = 2;
1824   int f = 2;
1825   int p = 2;
1826
1827   record_test_name(tcase_name());
1828
1829   record_failure_line_num(__LINE__);
1830   ck_assert_ldouble_eq_tol(3%d, 2%f, 2%p);
1831 }
1832 END_TEST
1833
1834 START_TEST(test_ck_assert_ldouble_ne_tol)
1835 {
1836   long double x = 0.0001l;
1837   long double y = 0.0002l;
1838   long double t = 0.0001l;
1839
1840   record_test_name(tcase_name());
1841
1842   ck_assert_ldouble_ne_tol(x, y, t);
1843   x*=10.0l;
1844   y*=10.0l;
1845   t*=10.0l;
1846   ck_assert_ldouble_ne_tol(x, y, t);
1847   t*=10.0l;
1848   record_failure_line_num(__LINE__);
1849   ck_assert_ldouble_ne_tol(x, y, t);
1850 }
1851 END_TEST
1852
1853 START_TEST(test_ck_assert_ldouble_ne_tol_with_mod)
1854 {
1855   int d = 2;
1856   int f = 2;
1857   int p = 2;
1858
1859   record_test_name(tcase_name());
1860
1861   record_failure_line_num(__LINE__);
1862   ck_assert_ldouble_ne_tol(3%d, 3%f, 3%p);
1863 }
1864 END_TEST
1865
1866 START_TEST(test_ck_assert_ldouble_ge_tol)
1867 {
1868   long double x = 0.001l;
1869   long double y = 0.003l;
1870   long double t = 0.001l;
1871
1872   record_test_name(tcase_name());
1873
1874   ck_assert_ldouble_ge_tol(y, x, t);
1875   ck_assert_ldouble_ge_tol(x, x, t);
1876   ck_assert_ldouble_ge_tol(y, y, t);
1877   x*=10.0l;
1878   y*=10.0l;
1879   t*=10.0l;
1880   ck_assert_ldouble_ge_tol(y, x, t);
1881   ck_assert_ldouble_ge_tol(x, x, t);
1882   ck_assert_ldouble_ge_tol(y, y, t);
1883   record_failure_line_num(__LINE__);
1884   ck_assert_ldouble_ge_tol(x, y, t);
1885 }
1886 END_TEST
1887
1888 START_TEST(test_ck_assert_ldouble_ge_tol_with_mod)
1889 {
1890   int d = 2;
1891   int f = 2;
1892   int p = 2;
1893
1894   record_test_name(tcase_name());
1895
1896   record_failure_line_num(__LINE__);
1897   ck_assert_ldouble_ge_tol(2%d, 3%f, 3%p);
1898 }
1899 END_TEST
1900
1901 START_TEST(test_ck_assert_ldouble_le_tol)
1902 {
1903   long double x = 0.001l;
1904   long double y = 0.003l;
1905   long double t = 0.001l;
1906
1907   record_test_name(tcase_name());
1908
1909   ck_assert_ldouble_le_tol(x, y, t);
1910   ck_assert_ldouble_le_tol(x, x, t);
1911   ck_assert_ldouble_le_tol(y, y, t);
1912   x*=10.0l;
1913   y*=10.0l;
1914   t*=10.0l;
1915   ck_assert_ldouble_le_tol(x, y, t);
1916   ck_assert_ldouble_le_tol(x, x, t);
1917   ck_assert_ldouble_le_tol(y, y, t);
1918   record_failure_line_num(__LINE__);
1919   ck_assert_ldouble_le_tol(y, x, t);
1920 }
1921 END_TEST
1922
1923 START_TEST(test_ck_assert_ldouble_le_tol_with_mod)
1924 {
1925   int d = 2;
1926   int f = 2;
1927   int p = 2;
1928
1929   record_test_name(tcase_name());
1930
1931   record_failure_line_num(__LINE__);
1932   ck_assert_ldouble_le_tol(3%d, 2%f, 3%p);
1933 }
1934 END_TEST
1935
1936 START_TEST(test_ck_assert_ldouble_tol_with_expr)
1937 {
1938   long double x[] = {NAN, 1.1l, 1.1l, 1.2l, 1.2l, NAN};
1939   long double y = 1.1l;
1940   long double t = 0.01l;
1941   int i;
1942
1943   record_test_name(tcase_name());
1944
1945   i = 1;
1946   ck_assert_ldouble_eq_tol(x[i++], y, t);
1947   ck_assert_ldouble_eq_tol(x[i++], y, t);
1948
1949   i = 4;
1950   ck_assert_ldouble_ne_tol(x[i--], y, t);
1951   ck_assert_ldouble_ne_tol(x[i--], y, t);
1952
1953   y = 1.15l;
1954
1955   i = 1;
1956   ck_assert_ldouble_le_tol(x[i++], y, t);
1957   ck_assert_ldouble_le_tol(x[i++], y, t);
1958
1959   i = 4;
1960   ck_assert_ldouble_ge_tol(x[i--], y, t);
1961   ck_assert_ldouble_ge_tol(x[i--], y, t);
1962 }
1963 END_TEST
1964
1965 START_TEST(test_ck_assert_ldouble_finite)
1966 {
1967   long double x = 0.0001l;
1968   long double t = 1.0l;
1969
1970   record_test_name(tcase_name());
1971
1972   ck_assert_ldouble_finite(x);
1973   /* MS VS doesn't allow explicit division by zero */
1974   x = 1.0l / (1.0l - t);
1975   record_failure_line_num(__LINE__);
1976   ck_assert_ldouble_finite(x);
1977 }
1978 END_TEST
1979
1980 START_TEST(test_ck_assert_ldouble_finite_with_mod)
1981 {
1982   int d = 2;
1983   long double t = 1.0l;
1984   long double x = 1.0l / (1.0l - t);
1985
1986   record_test_name(tcase_name());
1987
1988   record_failure_line_num(__LINE__);
1989   ck_assert_ldouble_finite(x*(1%d));
1990 }
1991 END_TEST
1992
1993 START_TEST(test_ck_assert_ldouble_infinite)
1994 {
1995   long double t = 1.0l;
1996   long double x = 1.0l / (1.0l - t);
1997
1998   record_test_name(tcase_name());
1999
2000   ck_assert_ldouble_infinite(x);
2001   x = -1.0l / (1.0l - t);
2002   ck_assert_ldouble_infinite(x);
2003   x = 0.0l;
2004   record_failure_line_num(__LINE__);
2005   ck_assert_ldouble_infinite(x);
2006 }
2007 END_TEST
2008
2009 START_TEST(test_ck_assert_ldouble_infinite_with_mod)
2010 {
2011   int d = 2;
2012
2013   record_test_name(tcase_name());
2014
2015   record_failure_line_num(__LINE__);
2016   ck_assert_ldouble_infinite(2%d);
2017 }
2018 END_TEST
2019
2020 START_TEST(test_ck_assert_ldouble_nan)
2021 {
2022   long double t = 1.0l;
2023   long double x = 0.0l / (1.0l - t);
2024
2025   record_test_name(tcase_name());
2026
2027   ck_assert_ldouble_nan(x);
2028   x = 1.0l / (1.0l - t);
2029   record_failure_line_num(__LINE__);
2030   ck_assert_ldouble_nan(x);
2031 }
2032 END_TEST
2033
2034 START_TEST(test_ck_assert_ldouble_nan_with_mod)
2035 {
2036   int d = 2;
2037
2038   record_test_name(tcase_name());
2039
2040   record_failure_line_num(__LINE__);
2041   ck_assert_ldouble_nan(2%d);
2042 }
2043 END_TEST
2044
2045 START_TEST(test_ck_assert_ldouble_nonnan)
2046 {
2047   long double x = 0.0l;
2048   long double t = 1.0l;
2049
2050   record_test_name(tcase_name());
2051
2052   ck_assert_ldouble_nonnan(x);
2053 #if ENABLE_REGEX
2054   x = 0.0l / (1.0l - t);
2055   record_failure_line_num(__LINE__);
2056   ck_assert_ldouble_nonnan(x);
2057 #else
2058   (void)t; /* unused */
2059 #endif
2060 }
2061 END_TEST
2062
2063 START_TEST(test_ck_assert_ldouble_nonnan_with_mod)
2064 {
2065   int s = 2;
2066   long double t = 1.0l;
2067   long double x;
2068
2069   record_test_name(tcase_name());
2070
2071   ck_assert_ldouble_nonnan(2%s);
2072 #if ENABLE_REGEX
2073   x = 0.0l / (1.0l - t);
2074   record_failure_line_num(__LINE__);
2075   ck_assert_ldouble_nonnan((2%s)*x);
2076 #else
2077   (void)t; /* unused */
2078   (void)x; /* unused */
2079 #endif
2080 }
2081 END_TEST
2082
2083 START_TEST(test_ck_assert_ldouble_nan_and_inf_with_expr)
2084 {
2085   long double x[] = {0.0l, 0.0l, INFINITY, INFINITY, NAN, NAN, 0.0l, 0.0l, NAN};
2086   int i = 0;
2087
2088   record_test_name(tcase_name());
2089
2090   ck_assert_ldouble_finite(x[i++]);
2091   ck_assert_ldouble_finite(x[i++]);
2092   ck_assert_ldouble_infinite(x[i++]);
2093   ck_assert_ldouble_infinite(x[i++]);
2094   ck_assert_ldouble_nan(x[i++]);
2095   ck_assert_ldouble_nan(x[i++]);
2096   ck_assert_ldouble_nonnan(x[i++]);
2097   ck_assert_ldouble_nonnan(x[i++]);
2098 }
2099 END_TEST
2100
2101 int returnsZero(const char* argument);
2102 int returnsZero(const char* argument)
2103 {
2104     (void)argument;
2105     return 0;
2106 }
2107
2108 START_TEST(test_percent_n_escaped)
2109 {
2110   record_test_name(tcase_name());
2111
2112   /* If the %n is not escaped in the ck macro, then this results in a SEGFAULT */
2113   record_failure_line_num(__LINE__);
2114   ck_assert_int_eq(returnsZero("%n"), 1);
2115 } END_TEST
2116
2117 START_TEST(test_ck_assert_str_eq)
2118 {
2119   const char *s = "test2";
2120
2121   record_test_name(tcase_name());
2122
2123   ck_assert_str_eq("test2", s);
2124   record_failure_line_num(__LINE__);
2125   ck_assert_str_eq("test1", s);
2126 }
2127 END_TEST
2128
2129 START_TEST(test_ck_assert_str_eq_with_null)
2130 {
2131   const char *s = NULL;
2132   const char *t = NULL;
2133
2134   record_test_name(tcase_name());
2135
2136   record_failure_line_num(__LINE__);
2137   ck_assert_str_eq(t, s);
2138 }
2139 END_TEST
2140
2141 START_TEST(test_ck_assert_str_ne)
2142 {
2143   const char *s = "test2";
2144   const char *t = "test1";
2145
2146   record_test_name(tcase_name());
2147
2148   ck_assert_str_ne(t, s);
2149   t = "test2";
2150   record_failure_line_num(__LINE__);
2151   ck_assert_str_ne(t, s);
2152 }
2153 END_TEST
2154
2155 START_TEST(test_ck_assert_str_ne_with_null)
2156 {
2157   const char *s = NULL;
2158   const char *t = "test";
2159
2160   record_test_name(tcase_name());
2161
2162   record_failure_line_num(__LINE__);
2163   ck_assert_str_ne(t, s);
2164 }
2165 END_TEST
2166
2167 START_TEST(test_ck_assert_str_lt)
2168 {
2169   const char *s = "test1";
2170   const char *t = "test2";
2171
2172   record_test_name(tcase_name());
2173
2174   ck_assert_str_lt(s, t);
2175   record_failure_line_num(__LINE__);
2176   ck_assert_str_lt(s, s);
2177 }
2178 END_TEST
2179
2180 START_TEST(test_ck_assert_str_lt_with_null)
2181 {
2182   const char *s = NULL;
2183   const char *t = "test";
2184
2185   record_test_name(tcase_name());
2186
2187   record_failure_line_num(__LINE__);
2188   ck_assert_str_lt(s, t);
2189 }
2190 END_TEST
2191
2192 START_TEST(test_ck_assert_str_le)
2193 {
2194   const char *s = "test1";
2195   const char *t = "test2";
2196
2197   record_test_name(tcase_name());
2198
2199   ck_assert_str_le(s, t);
2200   ck_assert_str_le(s, s);
2201   record_failure_line_num(__LINE__);
2202   ck_assert_str_le(t, s);
2203 }
2204 END_TEST
2205
2206 START_TEST(test_ck_assert_str_le_with_null)
2207 {
2208   const char *s = NULL;
2209   const char *t = NULL;
2210
2211   record_test_name(tcase_name());
2212
2213   record_failure_line_num(__LINE__);
2214   ck_assert_str_le(t, s);
2215 }
2216 END_TEST
2217
2218 START_TEST(test_ck_assert_str_gt)
2219 {
2220   const char *s = "test1";
2221   const char *t = "test2";
2222
2223   record_test_name(tcase_name());
2224
2225   ck_assert_str_gt(t, s);
2226   record_failure_line_num(__LINE__);
2227   ck_assert_str_gt(t, t);
2228 }
2229 END_TEST
2230
2231 START_TEST(test_ck_assert_str_gt_with_null)
2232 {
2233   const char *s = NULL;
2234   const char *t = "test";
2235
2236   record_test_name(tcase_name());
2237
2238   record_failure_line_num(__LINE__);
2239   ck_assert_str_gt(t, s);
2240 }
2241 END_TEST
2242
2243 START_TEST(test_ck_assert_str_ge)
2244 {
2245   const char *s = "test1";
2246   const char *t = "test2";
2247
2248   record_test_name(tcase_name());
2249
2250   ck_assert_str_ge(t, s);
2251   ck_assert_str_ge(t, t);
2252   record_failure_line_num(__LINE__);
2253   ck_assert_str_ge(s, t);
2254 }
2255 END_TEST
2256
2257 START_TEST(test_ck_assert_str_ge_with_null)
2258 {
2259   const char *s = NULL;
2260   const char *t = NULL;
2261
2262   record_test_name(tcase_name());
2263
2264   record_failure_line_num(__LINE__);
2265   ck_assert_str_ge(s, t);
2266 }
2267 END_TEST
2268
2269 START_TEST(test_ck_assert_str_expr)
2270 {
2271   const char *s = "test1";
2272   const char *t[] = { "test1", "test2" };
2273   int i = -1;
2274
2275   record_test_name(tcase_name());
2276
2277   ck_assert_str_eq(s, t[++i]);
2278   ck_assert_str_eq(s, t[i]);
2279 }
2280 END_TEST
2281
2282 START_TEST(test_ck_assert_pstr_eq)
2283 {
2284   const char *s = "test";
2285
2286   record_test_name(tcase_name());
2287
2288   ck_assert_pstr_eq("test", s);
2289   ck_assert_pstr_eq(NULL, NULL);
2290   record_failure_line_num(__LINE__);
2291   ck_assert_pstr_eq("test1", s);
2292 }
2293 END_TEST
2294
2295 START_TEST(test_ck_assert_pstr_eq_with_null)
2296 {
2297   const char *t = "test";
2298   const char *s = NULL;
2299
2300   record_test_name(tcase_name());
2301
2302   record_failure_line_num(__LINE__);
2303   ck_assert_pstr_eq(t, s);
2304 }
2305 END_TEST
2306
2307 START_TEST(test_ck_assert_pstr_ne)
2308 {
2309   const char *t = "test1";
2310   const char *s = "test2";
2311
2312   record_test_name(tcase_name());
2313
2314   ck_assert_pstr_ne(t, s);
2315   ck_assert_pstr_ne(t, NULL);
2316   t = "test2";
2317   record_failure_line_num(__LINE__);
2318   ck_assert_pstr_ne(t, s);
2319 }
2320 END_TEST
2321
2322 START_TEST(test_ck_assert_pstr_ne_with_null)
2323 {
2324   const char *s = NULL;
2325   const char *t = NULL;
2326
2327   record_test_name(tcase_name());
2328
2329   record_failure_line_num(__LINE__);
2330   ck_assert_pstr_ne(t, s);
2331 }
2332 END_TEST
2333
2334 START_TEST(test_ck_assert_ptr_eq)
2335 {
2336   int * x = (int*)0x1;
2337   int * y = (int*)0x2;
2338
2339   record_test_name(tcase_name());
2340
2341   ck_assert_ptr_eq(NULL, NULL);
2342   ck_assert_ptr_eq(x,    x);
2343   record_failure_line_num(__LINE__);
2344   ck_assert_ptr_eq(x,    y);
2345 }
2346 END_TEST
2347
2348 START_TEST(test_ck_assert_ptr_ne)
2349 {
2350   int * x = (int*)0x1;
2351   int * y = (int*)0x2;
2352   int * z = x;
2353
2354   record_test_name(tcase_name());
2355
2356   ck_assert_ptr_ne(x,    y);
2357   ck_assert_ptr_ne(x,    NULL);
2358   ck_assert_ptr_ne(NULL, y);
2359   record_failure_line_num(__LINE__);
2360   ck_assert_ptr_ne(x,    z);
2361 }
2362 END_TEST
2363
2364 START_TEST(test_ck_assert_ptr_null)
2365 {
2366   void* x = (void*)0x1;
2367   void* y = NULL;
2368
2369   record_test_name(tcase_name());
2370
2371   ck_assert_ptr_null(y);
2372   record_failure_line_num(__LINE__);
2373   ck_assert_ptr_null(x);
2374 }
2375 END_TEST
2376
2377 START_TEST(test_ck_assert_ptr_nonnull)
2378 {
2379   void* x = NULL;
2380   void* y = (void*)0x1;
2381
2382   record_test_name(tcase_name());
2383
2384   ck_assert_ptr_nonnull(y);
2385   record_failure_line_num(__LINE__);
2386   ck_assert_ptr_nonnull(x);
2387 }
2388 END_TEST
2389
2390 START_TEST(test_ck_assert_mem_eq)
2391 {
2392   const char *s = "\x00\x00\x00\x00\x02";
2393
2394   record_test_name(tcase_name());
2395
2396   ck_assert_mem_eq("\x00\x00\x00\x00\x02", s, 5);
2397   record_failure_line_num(__LINE__);
2398   ck_assert_mem_eq("\x00\x00\x00\x00\x01", s, 5);
2399 }
2400 END_TEST
2401
2402 START_TEST(test_ck_assert_mem_ne)
2403 {
2404   const char *s = "\x00\x00\x00\x00\x02";
2405   const char *t = "\x00\x00\x00\x00\x01";
2406
2407   record_test_name(tcase_name());
2408
2409   ck_assert_mem_ne(t, s, 5);
2410   t = "\x00\x00\x00\x00\x02";
2411   record_failure_line_num(__LINE__);
2412   ck_assert_mem_ne(t, s, 5);
2413 }
2414 END_TEST
2415
2416 START_TEST(test_ck_assert_mem_lt)
2417 {
2418   const char *s = "\x00\x00\x00\x00\x01";
2419   const char *t = "\x00\x00\x00\x00\x02";
2420
2421   record_test_name(tcase_name());
2422
2423   ck_assert_mem_lt(s, t, 5);
2424   record_failure_line_num(__LINE__);
2425   ck_assert_mem_lt(s, s, 5);
2426 }
2427 END_TEST
2428
2429 START_TEST(test_ck_assert_mem_le)
2430 {
2431   const char *s = "\x00\x00\x00\x00\x01";
2432   const char *t = "\x00\x00\x00\x00\x02";
2433
2434   record_test_name(tcase_name());
2435
2436   ck_assert_mem_le(s, t, 5);
2437   ck_assert_mem_le(s, s, 5);
2438   record_failure_line_num(__LINE__);
2439   ck_assert_mem_le(t, s, 5);
2440 }
2441 END_TEST
2442
2443 START_TEST(test_ck_assert_mem_gt)
2444 {
2445   const char *s = "\x00\x00\x00\x00\x01";
2446   const char *t = "\x00\x00\x00\x00\x02";
2447
2448   record_test_name(tcase_name());
2449
2450   ck_assert_mem_gt(t, s, 5);
2451   record_failure_line_num(__LINE__);
2452   ck_assert_mem_gt(t, t, 5);
2453 }
2454 END_TEST
2455
2456 START_TEST(test_ck_assert_mem_ge)
2457 {
2458   const char *s = "\x00\x00\x00\x00\x01";
2459   const char *t = "\x00\x00\x00\x00\x02";
2460
2461   record_test_name(tcase_name());
2462
2463   ck_assert_mem_ge(t, s, 5);
2464   ck_assert_mem_ge(t, t, 5);
2465   record_failure_line_num(__LINE__);
2466   ck_assert_mem_ge(s, t, 5);
2467 }
2468 END_TEST
2469
2470 START_TEST(test_ck_assert_mem_zerolen)
2471 {
2472   const char *s = "\x00\x00\x00\x00\x02";
2473   const char *t = "\x00\x00\x00\x00\x01";
2474
2475   record_test_name(tcase_name());
2476
2477   ck_assert_mem_eq(t, s, 0);
2478 }
2479 END_TEST
2480
2481 START_TEST(test_ck_assert_mem_eq_exact)
2482 {
2483   const char *s = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02";
2484   const char *t = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01";
2485
2486   record_test_name(tcase_name());
2487
2488   record_failure_line_num(__LINE__);
2489   ck_assert_mem_eq(t, s, 64);
2490 }
2491 END_TEST
2492
2493 START_TEST(test_ck_assert_mem_eq_longer)
2494 {
2495   const char *s = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02";
2496   const char *t = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01";
2497
2498   record_test_name(tcase_name());
2499
2500   record_failure_line_num(__LINE__);
2501   ck_assert_mem_eq(t, s, 65);
2502 }
2503 END_TEST
2504
2505 #if defined(HAVE_FORK) && HAVE_FORK == 1
2506 START_TEST(test_segv_pass)
2507 {
2508   record_test_name(tcase_name());
2509   /*
2510    * This test is to be used when it would otherwise not cause a
2511    * failure. e.g., shen SIGSEGV is expected.
2512    */
2513   raise (SIGSEGV);
2514 }
2515 END_TEST
2516
2517 START_TEST(test_segv)
2518 {
2519   record_test_name(tcase_name());
2520   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2521   raise (SIGSEGV);
2522 }
2523 END_TEST
2524
2525 /* This test currently does not work on Cygwin, as it results in a
2526  * SIGSEGV instead of a SIGFPE. However, a simple program that installs
2527  * a SIGFPE handler then raise(SIGFPE) works as expected. Further
2528  * investigation is necessary. */
2529 #if !defined(__CYGWIN__)
2530 START_TEST(test_fpe)
2531 {
2532   record_test_name(tcase_name());
2533   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2534   raise (SIGFPE);
2535 }
2536 END_TEST
2537 #endif /* !defined(__CYGWIN__) */
2538
2539 /*
2540  * This test is to be used when the test is expected to throw signal 8,
2541  * but does not, resulting in a failure.
2542  */
2543 START_TEST(test_non_signal_8)
2544 {
2545   record_test_name(tcase_name());
2546   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2547   exit(0);
2548 }
2549 END_TEST
2550
2551 /* TODO:
2552    unit test running the same suite in succession */
2553
2554 /* This test currently does not work on Cygwin, as it results in a
2555  * SIGSEGV instead of a SIGFPE. However, a simple program that installs
2556  * a SIGFPE handler then raise(SIGFPE) works as expected. Further
2557  * investigation is necessary. */
2558 #if !defined(__CYGWIN__)
2559 START_TEST(test_mark_point)
2560 {
2561   int i;
2562   record_test_name(tcase_name());
2563   i = 0;
2564   i++;
2565   mark_point();
2566   record_failure_line_num(__LINE__-2); /* -2 as the failure is listed as from mark_point() */
2567   raise(SIGFPE);
2568   ck_abort_msg("Shouldn't reach here");
2569 }
2570 END_TEST
2571 #endif /* !defined(__CYGWIN__) */
2572
2573 #endif /* HAVE_FORK */
2574
2575 #if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
2576 START_TEST(test_eternal_fail)
2577 {
2578   record_test_name(tcase_name());
2579   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2580   for (;;)
2581     sleep(1);
2582 }
2583 END_TEST
2584
2585 /* 
2586  * Only include sub-second timing tests on systems
2587  * that support librt.
2588  */
2589 #ifdef HAVE_LIBRT
2590 START_TEST(test_sleep0_025_pass)
2591 {
2592   record_test_name(tcase_name());
2593   usleep(25*1000);
2594 }
2595 END_TEST
2596
2597 START_TEST(test_sleep1_pass)
2598 {
2599   record_test_name(tcase_name());
2600   sleep(1);
2601 }
2602 END_TEST
2603
2604 START_TEST(test_sleep1_fail)
2605 {
2606   record_test_name(tcase_name());
2607   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2608   sleep(1);
2609 }
2610 END_TEST
2611 #endif /* HAVE_LIBRT */
2612
2613 START_TEST(test_sleep2_pass)
2614 {
2615   record_test_name(tcase_name());
2616   sleep(2);
2617 }
2618 END_TEST
2619
2620 START_TEST(test_sleep2_fail)
2621 {
2622   record_test_name(tcase_name());
2623   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2624   sleep(2);
2625 }
2626 END_TEST
2627
2628 START_TEST(test_sleep5_pass)
2629 {
2630   record_test_name(tcase_name());
2631   sleep(5);
2632 }
2633 END_TEST
2634
2635 START_TEST(test_sleep5_fail)
2636 {
2637   record_test_name(tcase_name());
2638   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2639   sleep(5);
2640 }
2641 END_TEST
2642
2643 START_TEST(test_sleep9_pass)
2644 {
2645   record_test_name(tcase_name());
2646   sleep(9);
2647 }
2648 END_TEST
2649
2650 START_TEST(test_sleep9_fail)
2651 {
2652   record_test_name(tcase_name());
2653   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2654   sleep(9);
2655 }
2656 END_TEST
2657
2658 START_TEST(test_sleep14_fail)
2659 {
2660   record_test_name(tcase_name());
2661   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2662   sleep(14);
2663   exit(3);
2664 }
2665 END_TEST
2666 #endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
2667
2668 #if defined(HAVE_FORK) && HAVE_FORK==1
2669 START_TEST(test_early_exit)
2670 {
2671   record_test_name(tcase_name());
2672   record_failure_line_num(__LINE__-4); /* -4 as the failure is reported at START_TEST() */
2673   exit(EXIT_FAILURE);
2674 }
2675 END_TEST
2676 #endif /* HAVE_FORK */
2677
2678 /*
2679  * The following test will leak memory because it is calling
2680  * APIs inproperly. The leaked memory cannot be free'd, as
2681  * the methods to do so are static. (No user of Check should
2682  * call them directly).
2683  */
2684 #if MEMORY_LEAKING_TESTS_ENABLED
2685 START_TEST(test_null)
2686 {  
2687   Suite *s;
2688   TCase *tc;
2689   
2690   record_test_name(tcase_name());
2691
2692   s = suite_create(NULL);
2693   tc = tcase_create(NULL);
2694   suite_add_tcase (s, NULL);
2695   tcase_add_test (tc, NULL);
2696   srunner_free(srunner_create(NULL));
2697   srunner_run_all (NULL, (enum print_output)-1);
2698   srunner_free (NULL);
2699   record_failure_line_num(__LINE__);
2700   ck_abort_msg("Completed properly");
2701 }
2702 END_TEST
2703 #endif /* MEMORY_LEAKING_TESTS_ENABLED */
2704
2705 START_TEST(test_null_2)
2706 {
2707   SRunner *sr = srunner_create(NULL);
2708
2709   record_test_name(tcase_name());
2710
2711   srunner_run_all (sr, CK_NORMAL);
2712   srunner_free (sr);
2713   ck_assert_int_eq(suite_tcase(NULL, NULL), 0);
2714   record_failure_line_num(__LINE__);
2715   ck_abort_msg("Completed properly");
2716 }
2717 END_TEST
2718
2719 #if defined(HAVE_FORK) && HAVE_FORK==1
2720 START_TEST(test_fork1p_pass)
2721 {
2722   pid_t pid;
2723
2724   record_test_name(tcase_name());
2725
2726   if((pid = fork()) < 0) {
2727     ck_abort_msg("Failed to fork new process");
2728   } else if (pid > 0) {
2729     ck_assert_msg(1, NULL);
2730     kill(pid, SIGKILL);
2731   } else {
2732     for (;;) {
2733       sleep(1);
2734     }
2735   }
2736 }
2737 END_TEST
2738
2739 START_TEST(test_fork1p_fail)
2740 {
2741   pid_t pid;
2742   
2743   record_test_name(tcase_name());
2744
2745   if((pid = fork()) < 0) {
2746     ck_abort_msg("Failed to fork new process");
2747   } else if (pid > 0) {
2748     record_failure_line_num(__LINE__);
2749     ck_abort_msg("Expected fail");
2750     kill(pid, SIGKILL);
2751   } else {
2752     for (;;) {
2753       sleep(1);
2754     }
2755   }
2756 }
2757 END_TEST
2758
2759 START_TEST(test_fork1c_pass)
2760 {
2761   pid_t pid;
2762
2763   record_test_name(tcase_name());
2764   
2765   if((pid = check_fork()) < 0) {
2766     ck_abort_msg("Failed to fork new process");
2767   } else if (pid > 0) {
2768     check_waitpid_and_exit(pid);
2769   } else {
2770     ck_assert_msg(1, NULL);
2771     check_waitpid_and_exit(0);
2772   }
2773 }
2774 END_TEST
2775
2776 START_TEST(test_fork1c_fail)
2777 {
2778   pid_t pid;
2779
2780   record_test_name(tcase_name());
2781   
2782   if((pid = check_fork()) < 0) {
2783     ck_abort_msg("Failed to fork new process");
2784   } else if (pid == 0) {
2785     record_failure_line_num(__LINE__);
2786     ck_abort_msg("Expected fail");
2787     check_waitpid_and_exit(0);
2788   }
2789   check_waitpid_and_exit(pid);
2790 }
2791 END_TEST
2792
2793 START_TEST(test_fork2_pass)
2794 {
2795   pid_t pid;
2796   pid_t pid2;
2797   
2798   record_test_name(tcase_name());
2799
2800   if((pid = check_fork()) < 0) {
2801     ck_abort_msg("Failed to fork new process");
2802   } else if (pid > 0) {
2803     if((pid2 = check_fork()) < 0) {
2804       ck_abort_msg("Failed to fork new process");
2805     } else if (pid2 == 0) {
2806       ck_assert_msg(1, NULL);
2807       check_waitpid_and_exit(0);
2808     }
2809     check_waitpid_and_exit(pid2);
2810   }
2811   check_waitpid_and_exit(pid);
2812 }
2813 END_TEST
2814
2815 START_TEST(test_fork2_fail)
2816 {
2817   pid_t pid;
2818   pid_t pid2;
2819   
2820   record_test_name(tcase_name());
2821
2822   if((pid = check_fork()) < 0) {
2823     ck_abort_msg("Failed to fork new process");
2824   } else if (pid > 0) {
2825     if((pid2 = check_fork()) < 0) {
2826       ck_abort_msg("Failed to fork new process");
2827     } else if (pid2 == 0) {
2828       record_failure_line_num(__LINE__);
2829       ck_abort_msg("Expected fail");
2830       check_waitpid_and_exit(0);
2831     }
2832     check_waitpid_and_exit(pid2);
2833     ck_abort_msg("Expected fail");
2834   }
2835   check_waitpid_and_exit(pid);
2836 }
2837 END_TEST
2838 #endif /* HAVE_FORK */
2839
2840 #if defined(HAVE_FORK) && HAVE_FORK == 1
2841 #if MEMORY_LEAKING_TESTS_ENABLED
2842 START_TEST(test_invalid_set_fork_status)
2843 {
2844    Suite *s1;
2845    TCase *tc1;
2846    SRunner *sr;
2847
2848    record_test_name(tcase_name());
2849
2850    record_failure_line_num(__LINE__-9); /* -9 as the failure is reported at START_TEST() */
2851    s1 = suite_create ("suite1");
2852    tc1 = tcase_create ("tcase1");
2853    tcase_add_test (tc1, test_pass);
2854    sr = srunner_create(s1);
2855    srunner_set_fork_status (sr, (enum fork_status)-1);
2856    srunner_run_all(sr, CK_SILENT);
2857 }
2858 END_TEST
2859 #endif /* MEMORY_LEAKING_TESTS_ENABLED */
2860 #endif /* HAVE_FORK */
2861
2862 START_TEST(test_srunner)
2863 {
2864   Suite *s;
2865   SRunner *sr;
2866
2867   record_test_name(tcase_name());
2868
2869   s = suite_create("Check Servant3");
2870   ck_assert_msg(s != NULL, NULL);
2871   sr = srunner_create(NULL);
2872   ck_assert_msg(sr != NULL, NULL);
2873   srunner_add_suite(sr, s);
2874   srunner_free(sr);
2875
2876   sr = srunner_create(NULL);
2877   ck_assert_msg(sr != NULL, NULL);
2878   srunner_add_suite(sr, NULL);
2879   srunner_free(sr);
2880
2881   s = suite_create("Check Servant3");
2882   ck_assert_msg(s != NULL, NULL);
2883   sr = srunner_create(s);
2884   ck_assert_msg(sr != NULL, NULL);
2885   srunner_free(sr);
2886 }
2887 END_TEST
2888
2889 START_TEST(test_2nd_suite)
2890 {
2891   record_test_name(tcase_name());
2892   record_failure_line_num(__LINE__);
2893   ck_abort_msg("We failed");
2894 }
2895 END_TEST
2896
2897 Suite *make_sub2_suite(void)
2898 {
2899   Suite *s = suite_create("Check Servant2");
2900   TCase *tc = tcase_create("Core");
2901   suite_add_tcase(s, tc);
2902   tcase_add_test(tc, test_srunner);
2903   tcase_add_test(tc, test_2nd_suite);
2904
2905   return s;
2906 }
2907
2908 #if defined(HAVE_FORK) && HAVE_FORK == 1
2909 void exit_handler(void);
2910 void exit_handler ()
2911 {
2912   /* This exit handler should never be executed */
2913   while(1)
2914   {
2915     sleep(1);
2916   }
2917 }
2918
2919 START_TEST(test_ignore_exit_handlers)
2920 {
2921   int result;
2922
2923   record_test_name(tcase_name());
2924
2925   result = atexit(exit_handler);
2926   if(result != 0)
2927   {
2928     ck_abort_msg("Failed to set an exit handler, test cannot proceed");
2929   }
2930   record_failure_line_num(__LINE__);
2931   ck_abort();
2932 }
2933 END_TEST
2934 #endif /* HAVE_FORK */
2935
2936 Suite *make_sub_suite(void)
2937 {
2938   Suite *s;
2939
2940   TCase *tc_simple;
2941 #if defined(HAVE_FORK) && HAVE_FORK==1
2942   TCase *tc_signal;
2943 #endif
2944 #if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
2945 #if HAVE_DECL_SETENV
2946   TCase *tc_timeout_env_int;
2947   TCase *tc_timeout_env_double;
2948 #endif /* HAVE_DECL_SETENV */
2949   TCase *tc_timeout_default;
2950   TCase *tc_timeout_usr_int;
2951   TCase *tc_timeout_usr_double;
2952 #if HAVE_DECL_SETENV
2953   TCase *tc_timeout_env_scale_int;
2954   TCase *tc_timeout_scale_int;
2955   TCase *tc_timeout_usr_scale_int;
2956   TCase *tc_timeout_env_scale_double;
2957   TCase *tc_timeout_scale_double;
2958   TCase *tc_timeout_usr_scale_double;
2959 #endif /* HAVE_DECL_SETENV */
2960 #endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
2961   TCase *tc_limit;
2962 #if defined(HAVE_FORK) && HAVE_FORK==1
2963   TCase *tc_messaging_and_fork;
2964   TCase *tc_errors;
2965   TCase *tc_exit_handlers;
2966 #endif
2967
2968   s = suite_create("Check Servant");
2969
2970   tc_simple = tcase_create("Simple Tests");
2971 #if defined(HAVE_FORK) && HAVE_FORK==1
2972   tc_signal = tcase_create("Signal Tests");
2973 #endif /* HAVE_FORK */
2974 #if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
2975 #if HAVE_DECL_SETENV
2976   setenv("CK_DEFAULT_TIMEOUT", "6", 1);
2977   tc_timeout_env_int = tcase_create("Environment Integer Timeout Tests");
2978   unsetenv("CK_DEFAULT_TIMEOUT");
2979   setenv("CK_DEFAULT_TIMEOUT", "0.5", 1);
2980   tc_timeout_env_double = tcase_create("Environment Double Timeout Tests");
2981   unsetenv("CK_DEFAULT_TIMEOUT");
2982 #endif /* HAVE_DECL_SETENV */
2983   tc_timeout_default = tcase_create("Default Timeout Tests");
2984   tc_timeout_usr_int = tcase_create("User Integer Timeout Tests");
2985   tc_timeout_usr_double = tcase_create("User Double Timeout Tests");
2986 #if HAVE_DECL_SETENV
2987   setenv("CK_TIMEOUT_MULTIPLIER", "2", 1);
2988   tc_timeout_scale_int = tcase_create("Timeout Integer Scaling Tests");
2989   tc_timeout_usr_scale_int = tcase_create("User Integer Timeout Scaling Tests");
2990   setenv("CK_DEFAULT_TIMEOUT", "6", 1);
2991   tc_timeout_env_scale_int = tcase_create("Environment Integer Timeout Scaling Tests");
2992   unsetenv("CK_DEFAULT_TIMEOUT");
2993   unsetenv("CK_TIMEOUT_MULTIPLIER");
2994   
2995   setenv("CK_TIMEOUT_MULTIPLIER", "0.35", 1);
2996   tc_timeout_scale_double = tcase_create("Timeout Double Scaling Tests");
2997   tc_timeout_usr_scale_double = tcase_create("User Double Timeout Scaling Tests");
2998   setenv("CK_DEFAULT_TIMEOUT", "0.9", 1);
2999   tc_timeout_env_scale_double = tcase_create("Environment Double Timeout Scaling Tests");
3000   unsetenv("CK_DEFAULT_TIMEOUT");
3001   unsetenv("CK_TIMEOUT_MULTIPLIER");
3002 #endif /* HAVE_DECL_SETENV */
3003 #endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
3004   tc_limit = tcase_create("Limit Tests");
3005 #if defined(HAVE_FORK) && HAVE_FORK==1
3006   tc_messaging_and_fork = tcase_create("Msg and fork Tests");
3007   tc_errors = tcase_create("Check Errors Tests");
3008   tc_exit_handlers = tcase_create("Check Ignore Exit Handlers");
3009 #endif /* HAVE_FORK */
3010
3011   suite_add_tcase (s, tc_simple);
3012 #if defined(HAVE_FORK) && HAVE_FORK==1
3013   suite_add_tcase (s, tc_signal);
3014 #endif /* HAVE_FORK */
3015 #if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
3016 #if HAVE_DECL_SETENV
3017   suite_add_tcase (s, tc_timeout_env_int);
3018   suite_add_tcase (s, tc_timeout_env_double);
3019 #endif /* HAVE_DECL_SETENV */
3020   suite_add_tcase (s, tc_timeout_default);
3021   suite_add_tcase (s, tc_timeout_usr_int);
3022   suite_add_tcase (s, tc_timeout_usr_double);
3023
3024 #if HAVE_DECL_SETENV
3025   suite_add_tcase (s, tc_timeout_env_scale_int);
3026   suite_add_tcase (s, tc_timeout_env_scale_double);
3027   suite_add_tcase (s, tc_timeout_scale_int);
3028   suite_add_tcase (s, tc_timeout_scale_double);
3029   suite_add_tcase (s, tc_timeout_usr_scale_int);
3030   suite_add_tcase (s, tc_timeout_usr_scale_double);
3031 #endif /* HAVE_DECL_SETENV */
3032 #endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
3033   suite_add_tcase (s, tc_limit);
3034 #if defined(HAVE_FORK) && HAVE_FORK == 1
3035   suite_add_tcase (s, tc_messaging_and_fork);
3036   suite_add_tcase (s, tc_errors);
3037   suite_add_tcase (s, tc_exit_handlers);
3038 #endif
3039
3040   tcase_add_test (tc_simple, test_lno);
3041 #if defined(HAVE_FORK) && HAVE_FORK==1
3042   tcase_add_test (tc_simple, test_mark_lno);
3043 #endif
3044   tcase_add_test (tc_simple, test_pass);
3045   tcase_add_test (tc_simple, test_fail_unless);
3046   tcase_add_test (tc_simple, test_fail_if_pass);
3047   tcase_add_test (tc_simple, test_fail_if_fail);
3048   tcase_add_test (tc_simple, test_fail_null_msg);
3049 #if defined(__GNUC__)
3050   tcase_add_test (tc_simple, test_fail_no_msg);
3051 #endif /* __GNUC__ */
3052   tcase_add_test (tc_simple, test_fail_if_null_msg);
3053 #if defined(__GNUC__)
3054   tcase_add_test (tc_simple, test_fail_if_no_msg);
3055 #endif /* __GNUC__ */
3056   tcase_add_test (tc_simple, test_fail_vararg_msg_1);
3057   tcase_add_test (tc_simple, test_fail_vararg_msg_2);
3058   tcase_add_test (tc_simple, test_fail_vararg_msg_3);
3059 #if defined(__GNUC__)
3060   tcase_add_test (tc_simple, test_fail_empty);
3061 #endif /* __GNUC__ */
3062
3063   tcase_add_test (tc_simple, test_ck_abort);
3064   tcase_add_test (tc_simple, test_ck_abort_msg);
3065   tcase_add_test (tc_simple, test_ck_abort_msg_null);
3066   tcase_add_test (tc_simple, test_ck_assert);
3067   tcase_add_test (tc_simple, test_ck_assert_null);
3068   tcase_add_test (tc_simple, test_ck_assert_with_mod);
3069   tcase_add_test (tc_simple, test_ck_assert_int_eq);
3070   tcase_add_test (tc_simple, test_ck_assert_int_eq_with_mod);
3071   tcase_add_test (tc_simple, test_ck_assert_int_ne);
3072   tcase_add_test (tc_simple, test_ck_assert_int_ne_with_mod);
3073   tcase_add_test (tc_simple, test_ck_assert_int_lt);
3074   tcase_add_test (tc_simple, test_ck_assert_int_lt_with_mod);
3075   tcase_add_test (tc_simple, test_ck_assert_int_le);
3076   tcase_add_test (tc_simple, test_ck_assert_int_le_with_mod);
3077   tcase_add_test (tc_simple, test_ck_assert_int_gt);
3078   tcase_add_test (tc_simple, test_ck_assert_int_gt_with_mod);
3079   tcase_add_test (tc_simple, test_ck_assert_int_ge);
3080   tcase_add_test (tc_simple, test_ck_assert_int_ge_with_mod);
3081   tcase_add_test (tc_simple, test_ck_assert_int_expr);
3082   tcase_add_test (tc_simple, test_ck_assert_uint_eq);
3083   tcase_add_test (tc_simple, test_ck_assert_uint_eq_with_mod);
3084   tcase_add_test (tc_simple, test_ck_assert_uint_ne);
3085   tcase_add_test (tc_simple, test_ck_assert_uint_ne_with_mod);
3086   tcase_add_test (tc_simple, test_ck_assert_uint_lt);
3087   tcase_add_test (tc_simple, test_ck_assert_uint_lt_with_mod);
3088   tcase_add_test (tc_simple, test_ck_assert_uint_le);
3089   tcase_add_test (tc_simple, test_ck_assert_uint_le_with_mod);
3090   tcase_add_test (tc_simple, test_ck_assert_uint_gt);
3091   tcase_add_test (tc_simple, test_ck_assert_uint_gt_with_mod);
3092   tcase_add_test (tc_simple, test_ck_assert_uint_ge);
3093   tcase_add_test (tc_simple, test_ck_assert_uint_ge_with_mod);
3094   tcase_add_test (tc_simple, test_ck_assert_uint_expr);
3095   tcase_add_test (tc_simple, test_ck_assert_float_eq);
3096   tcase_add_test (tc_simple, test_ck_assert_float_eq_with_mod);
3097   tcase_add_test (tc_simple, test_ck_assert_float_ne);
3098   tcase_add_test (tc_simple, test_ck_assert_float_ne_with_mod);
3099   tcase_add_test (tc_simple, test_ck_assert_float_lt);
3100   tcase_add_test (tc_simple, test_ck_assert_float_lt_with_mod);
3101   tcase_add_test (tc_simple, test_ck_assert_float_le);
3102   tcase_add_test (tc_simple, test_ck_assert_float_le_with_mod);
3103   tcase_add_test (tc_simple, test_ck_assert_float_gt);
3104   tcase_add_test (tc_simple, test_ck_assert_float_gt_with_mod);
3105   tcase_add_test (tc_simple, test_ck_assert_float_ge);
3106   tcase_add_test (tc_simple, test_ck_assert_float_ge_with_mod);
3107   tcase_add_test (tc_simple, test_ck_assert_float_with_expr);
3108   tcase_add_test (tc_simple, test_ck_assert_float_eq_tol);
3109   tcase_add_test (tc_simple, test_ck_assert_float_eq_tol_with_mod);
3110   tcase_add_test (tc_simple, test_ck_assert_float_ne_tol);
3111   tcase_add_test (tc_simple, test_ck_assert_float_ne_tol_with_mod);
3112   tcase_add_test (tc_simple, test_ck_assert_float_ge_tol);
3113   tcase_add_test (tc_simple, test_ck_assert_float_ge_tol_with_mod);
3114   tcase_add_test (tc_simple, test_ck_assert_float_le_tol);
3115   tcase_add_test (tc_simple, test_ck_assert_float_le_tol_with_mod);
3116   tcase_add_test (tc_simple, test_ck_assert_float_tol_with_expr);
3117   tcase_add_test (tc_simple, test_ck_assert_float_finite);
3118   tcase_add_test (tc_simple, test_ck_assert_float_finite_with_mod);
3119   tcase_add_test (tc_simple, test_ck_assert_float_infinite);
3120   tcase_add_test (tc_simple, test_ck_assert_float_infinite_with_mod);
3121   tcase_add_test (tc_simple, test_ck_assert_float_nan);
3122   tcase_add_test (tc_simple, test_ck_assert_float_nan_with_mod);
3123   tcase_add_test (tc_simple, test_ck_assert_float_nonnan);
3124   tcase_add_test (tc_simple, test_ck_assert_float_nonnan_with_mod);
3125   tcase_add_test (tc_simple, test_ck_assert_float_nan_and_inf_with_expr);
3126   tcase_add_test (tc_simple, test_ck_assert_double_eq);
3127   tcase_add_test (tc_simple, test_ck_assert_double_eq_with_mod);
3128   tcase_add_test (tc_simple, test_ck_assert_double_eq_with_promotion);
3129   tcase_add_test (tc_simple, test_ck_assert_double_eq_with_conv);
3130   tcase_add_test (tc_simple, test_ck_assert_double_ne);
3131   tcase_add_test (tc_simple, test_ck_assert_double_ne_with_mod);
3132   tcase_add_test (tc_simple, test_ck_assert_double_lt);
3133   tcase_add_test (tc_simple, test_ck_assert_double_lt_with_mod);
3134   tcase_add_test (tc_simple, test_ck_assert_double_le);
3135   tcase_add_test (tc_simple, test_ck_assert_double_le_with_mod);
3136   tcase_add_test (tc_simple, test_ck_assert_double_gt);
3137   tcase_add_test (tc_simple, test_ck_assert_double_gt_with_mod);
3138   tcase_add_test (tc_simple, test_ck_assert_double_ge);
3139   tcase_add_test (tc_simple, test_ck_assert_double_ge_with_mod);
3140   tcase_add_test (tc_simple, test_ck_assert_double_with_expr);
3141   tcase_add_test (tc_simple, test_ck_assert_double_eq_tol);
3142   tcase_add_test (tc_simple, test_ck_assert_double_eq_tol_with_mod);
3143   tcase_add_test (tc_simple, test_ck_assert_double_ne_tol);
3144   tcase_add_test (tc_simple, test_ck_assert_double_ne_tol_with_mod);
3145   tcase_add_test (tc_simple, test_ck_assert_double_ge_tol);
3146   tcase_add_test (tc_simple, test_ck_assert_double_ge_tol_with_mod);
3147   tcase_add_test (tc_simple, test_ck_assert_double_le_tol);
3148   tcase_add_test (tc_simple, test_ck_assert_double_le_tol_with_mod);
3149   tcase_add_test (tc_simple, test_ck_assert_double_tol_with_expr);
3150   tcase_add_test (tc_simple, test_ck_assert_double_finite);
3151   tcase_add_test (tc_simple, test_ck_assert_double_finite_with_mod);
3152   tcase_add_test (tc_simple, test_ck_assert_double_infinite);
3153   tcase_add_test (tc_simple, test_ck_assert_double_infinite_with_mod);
3154   tcase_add_test (tc_simple, test_ck_assert_double_nan);
3155   tcase_add_test (tc_simple, test_ck_assert_double_nan_with_mod);
3156   tcase_add_test (tc_simple, test_ck_assert_double_nonnan);
3157   tcase_add_test (tc_simple, test_ck_assert_double_nonnan_with_mod);
3158   tcase_add_test (tc_simple, test_ck_assert_double_nan_and_inf_with_expr);
3159   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq);
3160   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq_with_mod);
3161   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq_with_promotion);
3162   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq_with_conv);
3163   tcase_add_test (tc_simple, test_ck_assert_ldouble_ne);
3164   tcase_add_test (tc_simple, test_ck_assert_ldouble_ne_with_mod);
3165   tcase_add_test (tc_simple, test_ck_assert_ldouble_lt);
3166   tcase_add_test (tc_simple, test_ck_assert_ldouble_lt_with_mod);
3167   tcase_add_test (tc_simple, test_ck_assert_ldouble_le);
3168   tcase_add_test (tc_simple, test_ck_assert_ldouble_le_with_mod);
3169   tcase_add_test (tc_simple, test_ck_assert_ldouble_gt);
3170   tcase_add_test (tc_simple, test_ck_assert_ldouble_gt_with_mod);
3171   tcase_add_test (tc_simple, test_ck_assert_ldouble_ge);
3172   tcase_add_test (tc_simple, test_ck_assert_ldouble_ge_with_mod);
3173   tcase_add_test (tc_simple, test_ck_assert_ldouble_with_expr);
3174   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq_tol);
3175   tcase_add_test (tc_simple, test_ck_assert_ldouble_eq_tol_with_mod);
3176   tcase_add_test (tc_simple, test_ck_assert_ldouble_ne_tol);
3177   tcase_add_test (tc_simple, test_ck_assert_ldouble_ne_tol_with_mod);
3178   tcase_add_test (tc_simple, test_ck_assert_ldouble_ge_tol);
3179   tcase_add_test (tc_simple, test_ck_assert_ldouble_ge_tol_with_mod);
3180   tcase_add_test (tc_simple, test_ck_assert_ldouble_le_tol);
3181   tcase_add_test (tc_simple, test_ck_assert_ldouble_le_tol_with_mod);
3182   tcase_add_test (tc_simple, test_ck_assert_ldouble_tol_with_expr);
3183   tcase_add_test (tc_simple, test_ck_assert_ldouble_finite);
3184   tcase_add_test (tc_simple, test_ck_assert_ldouble_finite_with_mod);
3185   tcase_add_test (tc_simple, test_ck_assert_ldouble_infinite);
3186   tcase_add_test (tc_simple, test_ck_assert_ldouble_infinite_with_mod);
3187   tcase_add_test (tc_simple, test_ck_assert_ldouble_nan);
3188   tcase_add_test (tc_simple, test_ck_assert_ldouble_nan_with_mod);
3189   tcase_add_test (tc_simple, test_ck_assert_ldouble_nonnan);
3190   tcase_add_test (tc_simple, test_ck_assert_ldouble_nonnan_with_mod);
3191   tcase_add_test (tc_simple, test_ck_assert_ldouble_nan_and_inf_with_expr);
3192   tcase_add_test (tc_simple, test_percent_n_escaped);
3193   tcase_add_test (tc_simple, test_ck_assert_str_eq);
3194   tcase_add_test (tc_simple, test_ck_assert_str_eq_with_null);
3195   tcase_add_test (tc_simple, test_ck_assert_str_ne);
3196   tcase_add_test (tc_simple, test_ck_assert_str_ne_with_null);
3197   tcase_add_test (tc_simple, test_ck_assert_str_lt);
3198   tcase_add_test (tc_simple, test_ck_assert_str_lt_with_null);
3199   tcase_add_test (tc_simple, test_ck_assert_str_le);
3200   tcase_add_test (tc_simple, test_ck_assert_str_le_with_null);
3201   tcase_add_test (tc_simple, test_ck_assert_str_gt);
3202   tcase_add_test (tc_simple, test_ck_assert_str_gt_with_null);
3203   tcase_add_test (tc_simple, test_ck_assert_str_ge);
3204   tcase_add_test (tc_simple, test_ck_assert_str_ge_with_null);
3205   tcase_add_test (tc_simple, test_ck_assert_str_expr);
3206   tcase_add_test (tc_simple, test_ck_assert_pstr_eq);
3207   tcase_add_test (tc_simple, test_ck_assert_pstr_eq_with_null);
3208   tcase_add_test (tc_simple, test_ck_assert_pstr_ne);
3209   tcase_add_test (tc_simple, test_ck_assert_pstr_ne_with_null);
3210   tcase_add_test (tc_simple, test_ck_assert_ptr_eq);
3211   tcase_add_test (tc_simple, test_ck_assert_ptr_ne);
3212   tcase_add_test (tc_simple, test_ck_assert_ptr_null);
3213   tcase_add_test (tc_simple, test_ck_assert_ptr_nonnull);
3214   tcase_add_test (tc_simple, test_ck_assert_mem_eq);
3215   tcase_add_test (tc_simple, test_ck_assert_mem_ne);
3216   tcase_add_test (tc_simple, test_ck_assert_mem_lt);
3217   tcase_add_test (tc_simple, test_ck_assert_mem_le);
3218   tcase_add_test (tc_simple, test_ck_assert_mem_gt);
3219   tcase_add_test (tc_simple, test_ck_assert_mem_ge);
3220   tcase_add_test (tc_simple, test_ck_assert_mem_zerolen);
3221   tcase_add_test (tc_simple, test_ck_assert_mem_eq_exact);
3222   tcase_add_test (tc_simple, test_ck_assert_mem_eq_longer);
3223
3224 #if defined(HAVE_FORK) && HAVE_FORK==1
3225   tcase_add_test (tc_signal, test_segv);
3226   tcase_add_test_raise_signal (tc_signal, test_segv_pass, 11); /* pass  */
3227   tcase_add_test_raise_signal (tc_signal, test_segv, 8);  /* error */
3228   tcase_add_test_raise_signal (tc_signal, test_non_signal_8, 8);  /* fail  */
3229   tcase_add_test_raise_signal (tc_signal, test_fail_unless, 8);  /* fail  */
3230 #if !defined(__CYGWIN__)
3231   tcase_add_test (tc_signal, test_fpe);
3232   tcase_add_test (tc_signal, test_mark_point);
3233 #endif /* !defined(__CYGWIN__) */
3234 #endif /* HAVE_FORK */
3235
3236 #if TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) && HAVE_FORK == 1
3237 #if HAVE_DECL_SETENV
3238   /* tc_timeout_env_int tests have a timeout of 6 seconds */
3239   tcase_add_test (tc_timeout_env_int, test_eternal_fail);
3240   tcase_add_test (tc_timeout_env_int, test_sleep2_pass);
3241   tcase_add_test (tc_timeout_env_int, test_sleep5_pass);
3242   tcase_add_test (tc_timeout_env_int, test_sleep9_fail);
3243   
3244   /* tc_timeout_env_double tests have a timeout of 0.5 seconds */
3245   tcase_add_test (tc_timeout_env_double, test_eternal_fail);
3246 #ifdef HAVE_LIBRT
3247   tcase_add_test (tc_timeout_env_double, test_sleep0_025_pass);
3248   tcase_add_test (tc_timeout_env_double, test_sleep1_fail);
3249 #endif /* HAVE_LIBRT */
3250   tcase_add_test (tc_timeout_env_double, test_sleep2_fail);
3251   tcase_add_test (tc_timeout_env_double, test_sleep5_fail);
3252   tcase_add_test (tc_timeout_env_double, test_sleep9_fail);
3253 #endif /* HAVE_DECL_SETENV */
3254
3255   /* tc_timeout_default tests have a timeout of 4 seconds */
3256   tcase_add_test (tc_timeout_default, test_eternal_fail);
3257 #ifdef HAVE_LIBRT
3258   tcase_add_test (tc_timeout_default, test_sleep0_025_pass);
3259   tcase_add_test (tc_timeout_default, test_sleep1_pass);
3260 #endif /* HAVE_LIBRT */
3261   tcase_add_test (tc_timeout_default, test_sleep2_pass);
3262   tcase_add_test (tc_timeout_default, test_sleep5_fail);
3263   tcase_add_test (tc_timeout_default, test_sleep9_fail);
3264
3265   tcase_set_timeout (tc_timeout_usr_int, 6);
3266   tcase_add_test (tc_timeout_usr_int, test_eternal_fail);
3267   tcase_add_test (tc_timeout_usr_int, test_sleep2_pass);
3268   tcase_add_test (tc_timeout_usr_int, test_sleep5_pass);
3269   tcase_add_test (tc_timeout_usr_int, test_sleep9_fail);
3270
3271   tcase_set_timeout (tc_timeout_usr_double, 0.5);
3272   tcase_add_test (tc_timeout_usr_double, test_eternal_fail);
3273 #ifdef HAVE_LIBRT
3274   tcase_add_test (tc_timeout_usr_double, test_sleep0_025_pass);
3275   tcase_add_test (tc_timeout_usr_double, test_sleep1_fail);
3276 #endif /* HAVE_LIBRT */
3277   tcase_add_test (tc_timeout_usr_double, test_sleep2_fail);
3278   tcase_add_test (tc_timeout_usr_double, test_sleep5_fail);
3279   tcase_add_test (tc_timeout_usr_double, test_sleep9_fail);
3280   
3281 #if HAVE_DECL_SETENV
3282   /* tc_timeout_env_scale_int tests have a timeout of 6 (time) * 2 (multiplier) = 12 seconds */
3283   tcase_add_test (tc_timeout_env_scale_int, test_eternal_fail);
3284 #ifdef HAVE_LIBRT
3285   tcase_add_test (tc_timeout_env_scale_int, test_sleep0_025_pass);
3286   tcase_add_test (tc_timeout_env_scale_int, test_sleep1_pass);
3287 #endif /* HAVE_LIBRT */
3288   tcase_add_test (tc_timeout_env_scale_int, test_sleep2_pass);
3289   tcase_add_test (tc_timeout_env_scale_int, test_sleep5_pass);
3290   tcase_add_test (tc_timeout_env_scale_int, test_sleep9_pass);
3291   tcase_add_test (tc_timeout_env_scale_int, test_sleep14_fail);
3292
3293   /* tc_timeout_env_scale_double tests have a timeout of 0.9 (time) * 0.4 (multiplier) = 0.36 seconds */
3294   tcase_add_test (tc_timeout_env_scale_double, test_eternal_fail);
3295 #ifdef HAVE_LIBRT
3296   tcase_add_test (tc_timeout_env_scale_double, test_sleep0_025_pass);
3297   tcase_add_test (tc_timeout_env_scale_double, test_sleep1_fail);
3298 #endif /* HAVE_LIBRT */
3299   tcase_add_test (tc_timeout_env_scale_double, test_sleep2_fail);
3300   tcase_add_test (tc_timeout_env_scale_double, test_sleep5_fail);
3301   tcase_add_test (tc_timeout_env_scale_double, test_sleep9_fail);
3302   tcase_add_test (tc_timeout_env_scale_double, test_sleep14_fail);
3303
3304   /* tc_timeout_scale_int tests have a timeout of 2 * 4 (default) = 8 seconds */
3305   tcase_add_test (tc_timeout_scale_int, test_eternal_fail);
3306 #ifdef HAVE_LIBRT
3307   tcase_add_test (tc_timeout_scale_int, test_sleep0_025_pass);
3308   tcase_add_test (tc_timeout_scale_int, test_sleep1_pass);
3309   tcase_add_test (tc_timeout_scale_int, test_sleep2_pass);
3310 #endif /* HAVE_LIBRT */
3311   tcase_add_test (tc_timeout_scale_int, test_sleep5_pass);
3312   tcase_add_test (tc_timeout_scale_int, test_sleep9_fail);
3313
3314   /* tc_timeout_scale_double tests have a timeout of 4 (default) * 0.3 (multiplier) = 1.6 second */
3315   tcase_add_test (tc_timeout_scale_double, test_eternal_fail);
3316 #ifdef HAVE_LIBRT
3317   tcase_add_test (tc_timeout_scale_double, test_sleep0_025_pass);
3318   tcase_add_test (tc_timeout_scale_double, test_sleep1_pass);
3319 #endif /* HAVE_LIBRT */
3320   tcase_add_test (tc_timeout_scale_double, test_sleep2_fail);
3321   tcase_add_test (tc_timeout_scale_double, test_sleep5_fail);
3322   tcase_add_test (tc_timeout_scale_double, test_sleep9_fail);
3323   
3324   setenv("CK_TIMEOUT_MULTIPLIER", "2", 1);
3325   tcase_set_timeout (tc_timeout_usr_scale_int, 6);
3326   unsetenv("CK_TIMEOUT_MULTIPLIER");
3327   tcase_add_test (tc_timeout_usr_scale_int, test_eternal_fail);
3328 #ifdef HAVE_LIBRT
3329   tcase_add_test (tc_timeout_usr_scale_int, test_sleep0_025_pass);
3330   tcase_add_test (tc_timeout_usr_scale_int, test_sleep1_pass);
3331 #endif /* HAVE_LIBRT */
3332   tcase_add_test (tc_timeout_usr_scale_int, test_sleep2_pass);
3333   tcase_add_test (tc_timeout_usr_scale_int, test_sleep5_pass);
3334   tcase_add_test (tc_timeout_usr_scale_int, test_sleep9_pass);
3335   tcase_add_test (tc_timeout_usr_scale_int, test_sleep14_fail);
3336   
3337   setenv("CK_TIMEOUT_MULTIPLIER", "0.4", 1);
3338   tcase_set_timeout (tc_timeout_usr_scale_double, 0.9);
3339   unsetenv("CK_TIMEOUT_MULTIPLIER");
3340   tcase_add_test (tc_timeout_usr_scale_double, test_eternal_fail);
3341 #ifdef HAVE_LIBRT
3342   tcase_add_test (tc_timeout_usr_scale_double, test_sleep0_025_pass);
3343   tcase_add_test (tc_timeout_usr_scale_double, test_sleep1_fail);
3344 #endif /* HAVE_LIBRT */
3345   tcase_add_test (tc_timeout_usr_scale_double, test_sleep2_fail);
3346   tcase_add_test (tc_timeout_usr_scale_double, test_sleep5_fail);
3347   tcase_add_test (tc_timeout_usr_scale_double, test_sleep9_fail);
3348   tcase_add_test (tc_timeout_usr_scale_double, test_sleep14_fail);
3349 #endif /* HAVE_DECL_SETENV */
3350 #endif /* TIMEOUT_TESTS_ENABLED && defined(HAVE_FORK) */
3351
3352 #if defined(HAVE_FORK) && HAVE_FORK==1
3353   tcase_add_test (tc_limit, test_early_exit);
3354 #endif /* HAVE_FORK */
3355 #if MEMORY_LEAKING_TESTS_ENABLED
3356   tcase_add_test (tc_limit, test_null);
3357 #endif /* MEMORY_LEAKING_TESTS_ENABLED */
3358   tcase_add_test (tc_limit, test_null_2);
3359
3360 #if defined(HAVE_FORK) && HAVE_FORK==1
3361   tcase_add_test (tc_messaging_and_fork, test_fork1p_pass);
3362   tcase_add_test (tc_messaging_and_fork, test_fork1p_fail);
3363   tcase_add_test (tc_messaging_and_fork, test_fork1c_pass);
3364   tcase_add_test (tc_messaging_and_fork, test_fork1c_fail);
3365   tcase_add_test (tc_messaging_and_fork, test_fork2_pass);
3366   tcase_add_test (tc_messaging_and_fork, test_fork2_fail);
3367
3368 #if MEMORY_LEAKING_TESTS_ENABLED
3369   tcase_add_test_raise_signal (tc_errors, test_invalid_set_fork_status, 2);
3370 #endif
3371
3372   tcase_add_test (tc_exit_handlers, test_ignore_exit_handlers);
3373 #endif /* HAVE_FORK */
3374
3375   return s;
3376 }