remove test/main.*
[liba.git] / test / version.h
blob85ee64de470fd6725f1929cba51b2ff372f4e6e9
1 #define MAIN_(x) A_CAST_2(x, _version)
2 #include "test.h"
3 #include "a/version.h"
5 int MAIN(int argc, char *argv[]) // NOLINT(misc-definitions-in-headers)
7 #if defined(__cplusplus)
8 a::version v000 = A_VERSION_C(0, 0, 0);
9 a::version v100 = A_VERSION_C(1, 0, 0);
10 a::version v010 = A_VERSION_C(0, 1, 0);
11 a::version v001 = A_VERSION_C(0, 0, 1);
12 v010.parse(".1");
14 TEST_BUG(v000 == v000);
15 TEST_BUG(v000 != v001);
17 TEST_BUG(v000 < v001);
18 TEST_BUG(v001 < v010);
19 TEST_BUG(v010 < v100);
21 TEST_BUG(v001 > v000);
22 TEST_BUG(v010 > v001);
23 TEST_BUG(v100 > v010);
25 TEST_BUG(v000 <= v001);
26 TEST_BUG(v001 <= v001);
27 TEST_BUG(v001 <= v010);
28 TEST_BUG(v010 <= v010);
29 TEST_BUG(v010 <= v100);
30 TEST_BUG(v100 <= v100);
32 TEST_BUG(v001 >= v000);
33 TEST_BUG(v001 >= v001);
34 TEST_BUG(v010 >= v001);
35 TEST_BUG(v010 >= v010);
36 TEST_BUG(v100 >= v010);
37 TEST_BUG(v100 >= v100);
39 #else /* !__cplusplus */
40 a_version v000 = A_VERSION_C(0, 0, 0);
41 a_version v100 = A_VERSION_C(1, 0, 0);
42 a_version v010 = A_VERSION_C(0, 1, 0);
43 a_version v001 = A_VERSION_C(0, 0, 1);
45 TEST_BUG(a_version_eq(&v000, &v000));
46 TEST_BUG(a_version_ne(&v000, &v001));
48 TEST_BUG(a_version_lt(&v000, &v001));
49 TEST_BUG(a_version_lt(&v001, &v010));
50 TEST_BUG(a_version_lt(&v010, &v100));
52 TEST_BUG(a_version_gt(&v001, &v000));
53 TEST_BUG(a_version_gt(&v010, &v001));
54 TEST_BUG(a_version_gt(&v100, &v010));
56 TEST_BUG(a_version_le(&v000, &v001));
57 TEST_BUG(a_version_le(&v001, &v001));
58 TEST_BUG(a_version_le(&v001, &v010));
59 TEST_BUG(a_version_le(&v010, &v010));
60 TEST_BUG(a_version_le(&v010, &v100));
61 TEST_BUG(a_version_le(&v100, &v100));
63 TEST_BUG(a_version_ge(&v001, &v000));
64 TEST_BUG(a_version_ge(&v001, &v001));
65 TEST_BUG(a_version_ge(&v010, &v001));
66 TEST_BUG(a_version_ge(&v010, &v010));
67 TEST_BUG(a_version_ge(&v100, &v010));
68 TEST_BUG(a_version_ge(&v100, &v100));
70 TEST_BUG(a_version_cmp(&v010, &v100) < 0);
71 TEST_BUG(a_version_cmp(&v001, &v010) < 0);
72 TEST_BUG(a_version_cmp(&v000, &v001) < 0);
73 TEST_BUG(a_version_cmp(&v100, &v010) > 0);
74 TEST_BUG(a_version_cmp(&v010, &v001) > 0);
75 TEST_BUG(a_version_cmp(&v001, &v000) > 0);
76 TEST_BUG(a_version_cmp(&v000, &v000) == 0);
77 #endif /* __cplusplus */
78 #if defined(__cplusplus) && (__cplusplus > 201100L)
79 A_ASSERT_BUILD(std::is_pod<a_version>::value);
80 #endif /* __cplusplus */
81 for (int i = 0; i < argc; ++i)
83 a_version ctx;
84 a_version_parse(&ctx, argv[i]);
85 debug("parse \"%s\" -> %u.%u.%u\n", argv[i], ctx.major, ctx.minor, ctx.third);
87 printf("%s\n", A_FUNC);
88 #if defined(__cplusplus)
89 printf("version %u.%u.%u+%" PRIu32 "\n", a::version::MAJOR, a::version::MINOR, a::version::PATCH, a::version::TWEAK);
90 #else /* !__cplusplus */
91 printf("version %u.%u.%u+%" PRIu32 "\n", a_version_major, a_version_minor, a_version_patch, a_version_tweak);
92 #endif /* __cplusplus */
93 TEST_BUG(a_version_check() == 0);
94 return 0;