Skip to content

Commit a477dd1

Browse files
committed
use charpint.hh
1 parent 4cdfb3e commit a477dd1

File tree

2 files changed

+86
-85
lines changed

2 files changed

+86
-85
lines changed

tests/func/test_integral.cc

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ typedef unsigned char unsigned_char;
3131
#include <ctl/stack.h>
3232

3333
#include "charpint.hh"
34+
3435
typedef char *charp;
3536
#define TK charp
37+
#define T int
3638
#define POD
37-
#define T float
3839
#include <ctl/map.h>
3940

4041
#define POD
@@ -107,18 +108,18 @@ void print_deq_int(deq_int *a)
107108

108109
int main(void)
109110
{
110-
#define TEST_LIST(type, v1, v2) \
111-
{ \
112-
type a = type##_init(); \
113-
type##_push_back(&a, v1); \
114-
type##_it found = type##_find(&a, v1); \
115-
assert(!type##_it_done(&found)); /* equal */ \
116-
type##_push_back(&a, v2); \
117-
type b = type##_copy(&a); \
118-
type##_sort(&a); /* compare */ \
119-
assert(type##_equal(&a, &b)); \
120-
type##_free(&a); \
121-
type##_free(&b); \
111+
#define TEST_LIST(type, v1, v2) \
112+
{ \
113+
type a = type##_init(); \
114+
type##_push_back(&a, v1); \
115+
type##_it found = type##_find(&a, v1); \
116+
assert(!type##_it_done(&found)); /* equal */ \
117+
type##_push_back(&a, v2); \
118+
type b = type##_copy(&a); \
119+
type##_sort(&a); /* compare */ \
120+
assert(type##_equal(&a, &b)); \
121+
type##_free(&a); \
122+
type##_free(&b); \
122123
}
123124

124125
TEST_LIST(deq_int, 1, 2);
@@ -136,11 +137,11 @@ int main(void)
136137
stack_uint8_t_free(&a);
137138
}
138139
{
139-
map_charpfloat a = map_charpfloat_init(NULL);
140-
map_charpfloat_insert(&a, 1.f); // compare
141-
map_charpfloat_it found = map_charpfloat_find(&a, 1.f);
142-
assert(!map_charpfloat_it_done(&found)); // equal
143-
map_charpfloat_free(&a);
140+
map_charpint a = map_charpint_init(NULL);
141+
map_charpint_insert(&a, 1.f); // compare
142+
map_charpint_it found = map_charpint_find(&a, 1.f);
143+
assert(!map_charpint_it_done(&found)); // equal
144+
map_charpint_free(&a);
144145
}
145146
TEST_LIST(vec_double, 1.0, 2.0);
146147
{

tests/func/test_swisstable.cc

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,44 @@ typedef char* charp;
2121
#include <unordered_set>
2222
#include <unordered_map>
2323

24-
#define FOREACH_METH(TEST) \
25-
TEST(SELF) \
26-
TEST(INSERT) \
27-
TEST(INSERT_FOUND) \
28-
TEST(CONTAINS) \
29-
TEST(CLEAR) \
30-
TEST(SWAP) \
31-
TEST(COUNT) \
32-
TEST(FIND) \
33-
TEST(COPY) \
34-
TEST(EQUAL) \
35-
TEST(REHASH) \
36-
TEST(RESERVE) \
37-
TEST(FIND_IF) \
24+
#define FOREACH_METH(TEST) \
25+
TEST(SELF) \
26+
TEST(INSERT) \
27+
TEST(INSERT_FOUND) \
28+
TEST(CONTAINS) \
29+
TEST(CLEAR) \
30+
TEST(SWAP) \
31+
TEST(COUNT) \
32+
TEST(FIND) \
33+
TEST(COPY) \
34+
TEST(EQUAL) \
35+
TEST(REHASH) \
36+
TEST(RESERVE) \
37+
TEST(FIND_IF) \
3838
TEST(FIND_IF_NOT)
3939

40-
#define FOREACH_DEBUG(TEST) \
41-
TEST(ERASE) \
42-
TEST(ERASE_IF) \
43-
TEST(ALL_OF) \
44-
TEST(ANY_OF) \
45-
TEST(NONE_OF) \
46-
TEST(COUNT_IF) \
47-
TEST(UNION) /* 20 */ \
48-
TEST(INTERSECTION) \
49-
TEST(DIFFERENCE) \
50-
TEST(SYMMETRIC_DIFFERENCE) \
51-
TEST(GENERATE) \
52-
TEST(GENERATE_N) \
53-
TEST(TRANSFORM) \
54-
TEST(COPY_IF) \
55-
TEST(EMPLACE) \
56-
TEST(EMPLACE_FOUND) \
57-
TEST(EMPLACE_HINT) /* 30 */ \
58-
TEST(MERGE) \
59-
TEST(MERGE_RANGE) \
60-
TEST(EXTRACT) /* 33 */ \
61-
TEST(INSERT_GENERIC) \
40+
#define FOREACH_DEBUG(TEST) \
41+
TEST(ERASE) \
42+
TEST(ERASE_IF) \
43+
TEST(ALL_OF) \
44+
TEST(ANY_OF) \
45+
TEST(NONE_OF) \
46+
TEST(COUNT_IF) \
47+
TEST(UNION) /* 20 */ \
48+
TEST(INTERSECTION) \
49+
TEST(DIFFERENCE) \
50+
TEST(SYMMETRIC_DIFFERENCE) \
51+
TEST(GENERATE) \
52+
TEST(GENERATE_N) \
53+
TEST(TRANSFORM) \
54+
TEST(COPY_IF) \
55+
TEST(EMPLACE) \
56+
TEST(EMPLACE_FOUND) \
57+
TEST(EMPLACE_HINT) /* 30 */ \
58+
TEST(MERGE) \
59+
TEST(MERGE_RANGE) \
60+
TEST(EXTRACT) /* 33 */ \
61+
TEST(INSERT_GENERIC) \
6262
TEST(REMOVE_IF)
6363

6464
#define GENERATE_ENUM(x) TEST_##x,
@@ -82,39 +82,39 @@ static const char *test_names[] = {
8282
""};
8383
#endif
8484

85-
#define CHECK(_x, _y) \
86-
{ \
87-
assert(_x.size == _y.size()); \
88-
if (_x.size > 0) \
89-
{ \
90-
size_t a_found = 0; \
91-
size_t b_found = 0; \
92-
foreach (hmap_charp, &_x, _it) \
93-
{ \
94-
str *_key = &_it.ref->key; \
95-
auto _found = _y.find(str_c_str(_key)); \
96-
assert(_found != _y.end()); \
97-
a_found++; \
98-
} \
99-
for (auto x : _y) \
100-
{ \
101-
const char *_key = x.first.c_str(); \
102-
hmap_charp_it _found = hmap_charp_find(&_x, key); \
103-
assert(!hmap_charp_it_done(&_found)); \
104-
strint_free(&d); \
105-
b_found++; \
106-
} \
107-
assert(a_found == b_found); \
108-
} \
85+
#define CHECK(_x, _y) \
86+
{ \
87+
assert(_x.size == _y.size()); \
88+
if (_x.size > 0) \
89+
{ \
90+
size_t a_found = 0; \
91+
size_t b_found = 0; \
92+
foreach (hmap_charp, &_x, _it) \
93+
{ \
94+
str *_key = &_it.ref->key; \
95+
auto _found = _y.find(str_c_str(_key)); \
96+
assert(_found != _y.end()); \
97+
a_found++; \
98+
} \
99+
for (auto x : _y) \
100+
{ \
101+
const char *_key = x.first.c_str(); \
102+
hmap_charp_it _found = hmap_charp_find(&_x, key); \
103+
assert(!hmap_charp_it_done(&_found)); \
104+
strint_free(&d); \
105+
b_found++; \
106+
} \
107+
assert(a_found == b_found); \
108+
} \
109109
}
110110

111-
#define CHECK_ITER(_it, b, _iter) \
112-
if (!hmap_charp_it_done(&_it)) \
113-
{ \
114-
assert(_iter != b.end()); \
115-
assert(*_it.ref->value == *(*_iter).value); \
116-
} \
117-
else \
111+
#define CHECK_ITER(_it, b, _iter) \
112+
if (!hmap_charp_it_done(&_it)) \
113+
{ \
114+
assert(_iter != b.end()); \
115+
assert(*_it.ref->value == *(*_iter).value); \
116+
} \
117+
else \
118118
assert(_iter == b.end())
119119

120120
#ifdef DEBUG

0 commit comments

Comments
 (0)