tests/test_compare.c

Sun, 15 Dec 2024 12:19:21 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 15 Dec 2024 12:19:21 +0100
changeset 1012
21884374edbb
parent 787
d0f02310aa47
permissions
-rw-r--r--

add documentation - resolves #431

787
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #include "cx/test.h"
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #include <limits.h>
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 #include <float.h>
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 #include "cx/compare.h"
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 #define test_compare_gen_subroutine(T, max_number, signed_type) \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 static CX_TEST_SUBROUTINE( \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 test_sub_cmp_##T, \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 cx_compare_func fnc \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 ) { \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 T m = max_number / 512; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 T x, y; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 x = (signed_type ? -3 : 3) * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 y = 5 * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 CX_TEST_ASSERT(fnc(&x, &y) < 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 CX_TEST_ASSERT(fnc(&y, &x) > 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 x = 120 * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 y = 348 * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 CX_TEST_ASSERT(fnc(&x, &y) < 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 CX_TEST_ASSERT(fnc(&y, &x) > 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 if (signed_type) { \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 x = -120 * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 y = -348 * m; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 CX_TEST_ASSERT(fnc(&x, &y) > 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 CX_TEST_ASSERT(fnc(&y, &x) < 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 } \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 x = y; \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 CX_TEST_ASSERT(fnc(&x, &y) == 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 CX_TEST_ASSERT(fnc(&y, &x) == 0); \
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 // type aliases for types containing space characters
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 typedef long long cx_longlong;
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 typedef unsigned long cx_ulong;
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 typedef unsigned long long cx_ulonglong;
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 // generate sub routines depending on the type
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 test_compare_gen_subroutine(int, INT_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 test_compare_gen_subroutine(long, LONG_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 test_compare_gen_subroutine(cx_longlong, LLONG_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 test_compare_gen_subroutine(int16_t, INT16_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 test_compare_gen_subroutine(int32_t, INT32_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 test_compare_gen_subroutine(int64_t, INT64_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 test_compare_gen_subroutine(unsigned, UINT_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 test_compare_gen_subroutine(cx_ulong, ULONG_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 test_compare_gen_subroutine(cx_ulonglong, ULLONG_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 test_compare_gen_subroutine(uint16_t, UINT16_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 test_compare_gen_subroutine(uint32_t, UINT32_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 test_compare_gen_subroutine(uint64_t, UINT64_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 test_compare_gen_subroutine(float, FLT_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 test_compare_gen_subroutine(double, DBL_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 test_compare_gen_subroutine(intptr_t, INTPTR_MAX, true)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 test_compare_gen_subroutine(uintptr_t, UINTPTR_MAX, false)
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 CX_TEST(test_compare_int) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_int, cx_cmp_int);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 CX_TEST(test_compare_long) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_long, cx_cmp_longint);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 CX_TEST(test_compare_longlong) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_cx_longlong, cx_cmp_longlong);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 CX_TEST(test_compare_int16_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_int16_t, cx_cmp_int16);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 CX_TEST(test_compare_int32_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_int32_t, cx_cmp_int32);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 CX_TEST(test_compare_int64_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_int64_t, cx_cmp_int64);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 CX_TEST(test_compare_unsigned) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_unsigned, cx_cmp_uint);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 CX_TEST(test_compare_ulong) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_cx_ulong, cx_cmp_ulongint);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 CX_TEST(test_compare_ulonglong) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_cx_ulonglong, cx_cmp_ulonglong);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 CX_TEST(test_compare_uint16_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_uint16_t, cx_cmp_uint16);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 CX_TEST(test_compare_uint32_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_uint32_t, cx_cmp_uint32);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 CX_TEST(test_compare_uint64_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_uint64_t, cx_cmp_uint64);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 CX_TEST(test_compare_float) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_float, cx_cmp_float);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 CX_TEST(test_compare_double) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_double, cx_cmp_double);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 CX_TEST(test_compare_intptr_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_intptr_t, cx_cmp_intptr);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 CX_TEST(test_compare_uintptr_t) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 CX_TEST_DO CX_TEST_CALL_SUBROUTINE(test_sub_cmp_uintptr_t, cx_cmp_uintptr);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 CX_TEST(test_compare_ptr) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 int data[3];
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 CX_TEST_DO {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 CX_TEST_ASSERT(0 == cx_cmp_ptr(data, data));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 CX_TEST_ASSERT(-1 == cx_cmp_ptr(&data[0], &data[1]));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 CX_TEST_ASSERT(-1 == cx_cmp_ptr(&data[1], &data[2]));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 CX_TEST_ASSERT(1 == cx_cmp_ptr(&data[2], &data[1]));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 CX_TEST_ASSERT(1 == cx_cmp_ptr(&data[1], data));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 CX_TEST_ASSERT(0 == cx_cmp_ptr(&data[1], &data[1]));
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 }
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161 CxTestSuite *cx_test_suite_compare(void) {
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 CxTestSuite *suite = cx_test_suite_new("compare");
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 cx_test_register(suite, test_compare_int);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 cx_test_register(suite, test_compare_long);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 cx_test_register(suite, test_compare_longlong);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 cx_test_register(suite, test_compare_int16_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 cx_test_register(suite, test_compare_int32_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 cx_test_register(suite, test_compare_int64_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 cx_test_register(suite, test_compare_unsigned);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 cx_test_register(suite, test_compare_ulong);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 cx_test_register(suite, test_compare_ulonglong);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173 cx_test_register(suite, test_compare_uint16_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 cx_test_register(suite, test_compare_uint32_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 cx_test_register(suite, test_compare_uint64_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 cx_test_register(suite, test_compare_float);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 cx_test_register(suite, test_compare_double);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 cx_test_register(suite, test_compare_intptr_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 cx_test_register(suite, test_compare_uintptr_t);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 cx_test_register(suite, test_compare_ptr);
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 return suite;
d0f02310aa47 migrate compare tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 }

mercurial