]> git.ozlabs.org Git - ccan/blob - ccan/order/test/run-fancy.c
Remove travis workarounds for previous build system
[ccan] / ccan / order / test / run-fancy.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdio.h>
4
5 #include <ccan/order/order.h>
6
7 #include <ccan/tap/tap.h>
8
9 #include "fancy_cmp.h"
10
11 int main(int argc, char *argv[])
12 {
13         struct item item1 = {
14                 .value = 0,
15                 .str = "aaa",
16         };
17         struct item item2 = {
18                 .value = 0,
19                 .str = "abb",
20         };
21         struct item item3 = {
22                 .value = 0x1000,
23                 .str = "baa",
24         };
25         struct cmp_info ctx1 = {
26                 .xcode = 0,
27                 .offset = 0,
28         };
29         struct cmp_info ctx2 = {
30                 .xcode = 0x1000,
31                 .offset = 1,
32         };
33         total_order(order1, struct item, struct cmp_info *) = {
34                 fancy_cmp, &ctx1,
35         };
36         total_order(order2, struct item, struct cmp_info *) = {
37                 fancy_cmp, &ctx2,
38         };
39
40         plan_tests(18);
41
42         ok1(total_order_cmp(order1, &item1, &item1) == 0);
43         ok1(total_order_cmp(order1, &item2, &item2) == 0);
44         ok1(total_order_cmp(order1, &item3, &item3) == 0);
45
46         ok1(total_order_cmp(order1, &item1, &item2) == -1);
47         ok1(total_order_cmp(order1, &item2, &item3) == -1);
48         ok1(total_order_cmp(order1, &item1, &item3) == -1);
49
50         ok1(total_order_cmp(order1, &item2, &item1) == 1);
51         ok1(total_order_cmp(order1, &item3, &item2) == 1);
52         ok1(total_order_cmp(order1, &item3, &item1) == 1);
53
54
55         ok1(total_order_cmp(order2, &item1, &item1) == 0);
56         ok1(total_order_cmp(order2, &item2, &item2) == 0);
57         ok1(total_order_cmp(order2, &item3, &item3) == 0);
58
59         ok1(total_order_cmp(order2, &item1, &item2) == 1);
60         ok1(total_order_cmp(order2, &item2, &item3) == 1);
61         ok1(total_order_cmp(order2, &item1, &item3) == 1);
62
63         ok1(total_order_cmp(order2, &item2, &item1) == -1);
64         ok1(total_order_cmp(order2, &item3, &item2) == -1);
65         ok1(total_order_cmp(order2, &item3, &item1) == -1);
66         
67         exit(0);
68 }