1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
|
#ifndef _TEST_H_
#define _TEST_H_
#define _XOPEN_SOURCE 700
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <wchar.h>
/****************************
* INTERNAL FUNCTIONALITY *
****************************/
int _test_mbslen(char *arg)
{
int blen = strlen(arg), clen = 0, i = 0;
wchar_t wc;
setlocale(LC_ALL, "");
while(i < blen) {
i += mbtowc(&wc, arg + i, blen - i);
clen += wcwidth(wc);
}
return clen;
}
void _test_get_escape(char c, char *buf)
{
buf[0] = '\\';
buf[2] = '\0';
switch(c) {
case '\a':
buf[1] = 'a';
break;
case '\b':
buf[1] = 'b';
break;
case '\t':
buf[1] = 't';
break;
case '\n':
buf[1] = 'n';
break;
case '\v':
buf[1] = 'v';
break;
case '\f':
buf[1] = 'f';
break;
case '\r':
buf[1] = 'r';
break;
default:
buf[0] = c;
buf[1] = '\0';
}
}
void _test_get_escape_wide(wchar_t c, wchar_t *buf)
{
buf[0] = L'\\';
buf[2] = L'\0';
switch(c) {
case L'\a':
buf[1] = L'a';
break;
case L'\b':
buf[1] = L'b';
break;
case L'\t':
buf[1] = L't';
break;
case L'\n':
buf[1] = L'n';
break;
case L'\v':
buf[1] = L'v';
break;
case L'\f':
buf[1] = L'f';
break;
case L'\r':
buf[1] = L'r';
break;
default:
buf[0] = c;
buf[1] = L'\0';
}
}
/* extra levels of abstraction are necessary
* to get __LINE__ to evaluate first */
#define _TEST_STRINGIFY(x) _TEST_STRINGIFY_EVAL(x)
#define _TEST_STRINGIFY_EVAL(x) \
#x
#define _TEST_LEN_DIFF(arg1, arg2) \
( _test_mbslen(arg1) - _test_mbslen(arg2) )
#define _TEST_FAIL_VAL(summary, format1, format2, expected, actual) \
do { \
_TEST_FAIL_VAL_REAL(summary, format1, format2, #actual, expected, actual); \
} while(0)
#define _TEST_FAIL_VAL_REAL(summary, format1, format2, sactual, expected, actual) \
do { \
{ \
int _test_i, _test_diff = _TEST_LEN_DIFF("expected", #actual); \
printf("\e[1m :: " __FILE__ ":" _TEST_STRINGIFY(__LINE__) ": \e[31;1mfail:\e[m " summary "\e[m\n"); \
printf("\e[1m :: \e[m\e[1m"); \
for(_test_i = 0; _test_i < -_test_diff; _test_i++) \
printf(" "); \
printf("expected:\e[m " format1 "\n", expected);\
printf("\e[1m :: \e[m\e[1m"); \
for(_test_i = 0; _test_i < _test_diff; _test_i++) \
printf(" "); \
printf(#actual ":\e[m " format2 "\e[m\n", actual); \
return 1; \
} \
} while(0)
#define _TEST_FAIL_EQ(summary, format1, format2, arg1, arg2) \
do { \
_TEST_FAIL_EQ_REAL(summary, format1, format2, #arg1, #arg2, arg1, arg2); \
} while(0)
#define _TEST_FAIL_EQ_REAL(summary, format1, format2, sarg1, sarg2, arg1, arg2) \
do { \
{ \
int _test_i, _test_diff = _TEST_LEN_DIFF(sarg1, sarg2); \
printf("\e[1m :: " __FILE__ ":" _TEST_STRINGIFY(__LINE__) ": \e[31;1mfail:\e[m " summary "\e[m\n"); \
printf("\e[1m :: "); \
for(_test_i = 0; _test_i < -_test_diff; _test_i++) \
printf(" "); \
printf(sarg1 " == \e[m" format1 "\n", arg1); \
printf("\e[1m :: "); \
for(_test_i = 0; _test_i < _test_diff; _test_i++) \
printf(" "); \
printf(sarg2 " == \e[m" format2 "\n", arg2); \
return 1; \
} \
} while(0)
/**********************
* TOP-LEVEL MACROS *
**********************/
/* the whole thing is inside one
* big function. yay! */
#define BEGIN_TEST \
int _test_count_current=1; \
int main(int argc, char *argv[]) \
{ \
printf("\e[1m" __FILE__ "\n");
/* yaaaay! */
#define END_TEST \
printf("\e[1m :: \e[m\e[32msuccess!\e[m\n"); \
return 0; \
}
#define TEST(description) \
printf("\e[1m%3i :: \e[m\e[33m%s\e[m\n", _test_count_current++, description);
/* pretty printing for the current state within
* a test */
#define ECHO(...) \
do { \
printf("\e[1m :: \e[m\e[34m"); \
printf(__VA_ARGS__); \
printf("...\e[m\n"); \
} while(0)
/***********
* TESTS *
***********/
#define EXPECT_NULL(arg) \
do { \
if((arg) != NULL) \
_TEST_FAIL_VAL("NULL value", "%s", "%p", "NULL", (void*)(arg)); \
} while(0);
#define EXPECT_NON_NULL(arg) \
do { \
if((arg) == NULL) \
_TEST_FAIL_VAL("non NULL value", "%s", "%p", "non NULL", (void*)(arg)); \
} while(0);
#define EXPECT_PNT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_PNT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %p", "%p", arg1, arg2); \
} while(0);
#define EXPECT_HEX(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> 0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= 0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< 0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_HEX_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= 0x%X", "0x%X", arg1, arg2); \
} while(0);
#define EXPECT_INT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_INT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_LINT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LINT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %li", "%li", arg1, arg2); \
} while(0);
#define EXPECT_LLINT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_LLINT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %lli", "%lli", arg1, arg2); \
} while(0);
#define EXPECT_UINT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_UINT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %u", "%u", arg1, arg2); \
} while(0);
#define EXPECT_LUINT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LUINT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %lu", "%lu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_LLUINT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %llu", "%llu", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%f", "%f", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%f", "%f", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %f", "%f", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %f", "%f", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %f", "%f", arg1, arg2); \
} while(0);
#define EXPECT_FLOAT_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_VAL("unexpected value", "%i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_EQ(arg1, arg2) \
do { \
if((arg1) != (arg2)) \
_TEST_FAIL_EQ("values do not match", "%Lf", "%Lf", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_NEQ(arg1, arg2) \
do { \
if((arg1) == (arg2)) \
_TEST_FAIL_EQ("values match", "%Lf", "%Lf", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_G(arg1, arg2) \
do { \
if((arg1) <= (arg2)) \
_TEST_FAIL_VAL(#arg1 "<=" #arg2, "> %Lf", "%Lf", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_GEQ(arg1, arg2) \
do { \
if((arg1) < (arg2)) \
_TEST_FAIL_VAL(#arg1 "<" #arg2, ">= %Lf", "%Lf", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_L(arg1, arg2) \
do { \
if((arg1) >= (arg2)) \
_TEST_FAIL_VAL(#arg1 ">=" #arg2, "< %Lf", "%Lf", arg1, arg2); \
} while(0);
#define EXPECT_LDOUBLE_LEQ(arg1, arg2) \
do { \
if((arg1) > (arg2)) \
_TEST_FAIL_VAL(#arg1 ">" #arg2, "<= %i", "%i", arg1, arg2); \
} while(0);
#define EXPECT_CHAR(arg1, arg2) \
do { \
{ \
char _test_buf1[3], _test_buf2[3]; \
_test_get_escape((arg1), _test_buf1); \
_test_get_escape((arg2), _test_buf2); \
if( strcmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_VAL_REAL("unexpected char value", \
"‘%s’","‘%s’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_CHAR_EQ(arg1, arg2) \
do { \
{ \
char _test_buf1[3], _test_buf2[3]; \
_test_get_escape((arg1), _test_buf1); \
_test_get_escape((arg2), _test_buf2); \
if( strcmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_EQ_REAL("chars unequal", \
"‘%s’", "‘%s’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_CHAR_NEQ(arg1, arg2) \
do { \
{ \
char _test_buf1[3], _test_buf2[3]; \
_test_get_escape((arg1), _test_buf1); \
_test_get_escape((arg2), _test_buf2); \
if( !strcmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_EQ_REAL("chars equal", \
"‘%s’", "‘%s’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_STR(arg1, arg2) \
do { \
if( strcmp(arg1, arg2) ) \
_TEST_FAIL_VAL("unexpected string value", "‘%s’", "‘%s’", arg1, arg2); \
} while(0);
#define EXPECT_STR_EQ(arg1, arg2) \
do { \
if( strcmp(arg1, arg2) ) \
_TEST_FAIL_EQ("strings unequal", "‘%s’", "‘%s’", arg1, arg2); \
} while(0);
#define EXPECT_STR_NEQ(arg1, arg2) \
do { \
if( !strcmp(arg1, arg2) ) \
_TEST_FAIL_EQ("strings equal", "‘%s’", "‘%s’", arg1, arg2); \
} while(0);
#define EXPECT_WCHAR(arg1, arg2) \
do { \
{ \
wchar_t _test_buf1[3], _test_buf2[3]; \
_test_get_escape_wide((arg1), _test_buf1); \
_test_get_escape_wide((arg2), _test_buf2); \
if( wcscmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_VAL_REAL("unexpected wchar value", \
"‘%ls’", "‘%ls’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_WCHAR_EQ(arg1, arg2) \
do { \
{ \
wchar_t _test_buf1[3], _test_buf2[3]; \
_test_get_escape_wide((arg1), _test_buf1); \
_test_get_escape_wide((arg2), _test_buf2); \
if( wcscmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_EQ_REAL("wchars unequal", \
"‘%ls’", "‘%ls’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_WCHAR_NEQ(arg1, arg2) \
do { \
{ \
wchar_t _test_buf1[3], _test_buf2[3]; \
_test_get_escape_wide((arg1), _test_buf1); \
_test_get_escape_wide((arg2), _test_buf2); \
if( !wcscmp(_test_buf1, _test_buf2) ) \
_TEST_FAIL_EQ_REAL("wchars equal", \
"‘%ls’", "‘%ls’", #arg1, #arg2, _test_buf1, _test_buf2); \
} \
} while(0);
#define EXPECT_WSTR(arg1, arg2) \
do { \
if( wcscmp(arg1, arg2) ) \
_TEST_FAIL_VAL("unexpected wide string value", "‘%ls’", "‘%ls’", arg1, arg2); \
} while(0);
#define EXPECT_WSTR_EQ(arg1, arg2) \
do { \
if( wcscmp(arg1, arg2) ) \
_TEST_FAIL_EQ("wide strings unequal", "‘%ls’", "‘%ls’", arg1, arg2); \
} while(0);
#define EXPECT_WSTR_NEQ(arg1, arg2) \
do { \
if( !wcscmp(arg1, arg2) ) \
_TEST_FAIL_EQ("wide strings equal", "‘%ls’", "‘%ls’", arg1, arg2); \
} while(0);
#endif
|