Last change
on this file since 64f3b9f was e7eb1f0, checked in by Peter A. Buhr <pabuhr@…>, 21 months ago |
update string testing and expected output
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | #define chk(X) \
|
---|
2 | printf( #X " %s\n", ((X)?"ok":"WRONG") );
|
---|
3 |
|
---|
4 | #define test_eq_(l, r) \
|
---|
5 | chk( (strcmp(l, r) == 0) ) \
|
---|
6 | chk( (l == r) ) \
|
---|
7 | chk( !(l != r) ) \
|
---|
8 | chk( !(l > r) ) \
|
---|
9 | chk( (l >= r) ) \
|
---|
10 | chk( (l <= r) ) \
|
---|
11 | chk( !(l < r) )
|
---|
12 |
|
---|
13 | #define test_eq(l, r) \
|
---|
14 | test_eq_(s_ ## l, s_ ## r) \
|
---|
15 | test_eq_( # l, s_ ## r) \
|
---|
16 | test_eq_(s_ ## l, # r)
|
---|
17 |
|
---|
18 | #define test_lt_(l, r) \
|
---|
19 | chk( (strcmp(l, r) < 0) ) \
|
---|
20 | chk( !(l == r) ) \
|
---|
21 | chk( (l != r) ) \
|
---|
22 | chk( !(l > r) ) \
|
---|
23 | chk( !(l >= r) ) \
|
---|
24 | chk( (l <= r) ) \
|
---|
25 | chk( (l < r) )
|
---|
26 |
|
---|
27 | #define test_gt_(l, r) \
|
---|
28 | chk( (strcmp(l, r) > 0) ) \
|
---|
29 | chk( !(l == r) ) \
|
---|
30 | chk( (l != r) ) \
|
---|
31 | chk( (l > r) ) \
|
---|
32 | chk( (l >= r) ) \
|
---|
33 | chk( !(l <= r) ) \
|
---|
34 | chk( !(l < r) )
|
---|
35 |
|
---|
36 | #define test_lt(l, r) \
|
---|
37 | test_lt_(s_ ## l, s_ ## r) \
|
---|
38 | test_lt_( # l, s_ ## r) \
|
---|
39 | test_lt_(s_ ## l, # r) \
|
---|
40 | test_gt_(s_ ## r, s_ ## l) \
|
---|
41 | test_gt_( # r, s_ ## l) \
|
---|
42 | test_gt_(s_ ## r, # l)
|
---|
43 |
|
---|
44 | #define define_run(STR_T) \
|
---|
45 | void run_ ## STR_T (void) { \
|
---|
46 | printf("------- %s -------\n", #STR_T); \
|
---|
47 | STR_T s_ = "" ; \
|
---|
48 | STR_T s_a = "a" ; \
|
---|
49 | STR_T s_aa = "aa"; \
|
---|
50 | STR_T s_ab = "ab"; \
|
---|
51 | STR_T s_b = "b" ; \
|
---|
52 | STR_T s_ba = "ba"; \
|
---|
53 | STR_T s_bb = "bb"; \
|
---|
54 | test_eq(,) \
|
---|
55 | test_lt(,a) \
|
---|
56 | test_lt(,aa) \
|
---|
57 | test_lt(a,aa) \
|
---|
58 | test_eq(a,a) \
|
---|
59 | test_eq(aa,aa) \
|
---|
60 | test_lt(a,b) \
|
---|
61 | test_lt(a,ba) \
|
---|
62 | test_lt(aa,ab) \
|
---|
63 | test_lt(ba,bb) \
|
---|
64 | test_lt(aa,b) \
|
---|
65 | }
|
---|
66 |
|
---|
67 | #include <collections/string.hfa>
|
---|
68 | define_run(string)
|
---|
69 |
|
---|
70 | #include <collections/string_res.hfa>
|
---|
71 | define_run(string_res)
|
---|
72 |
|
---|
73 | int main() {
|
---|
74 | run_string();
|
---|
75 | run_string_res();
|
---|
76 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.