Add test for ALGO_MAP
Fix issue with ALGO_MAP.
This commit is contained in:
1 parent
5bae6d0870
commit
0c22a620b9
2 files changed
+8
-2
No files matched your search
@@ -202,7 +202,8 @@
|
||||
|
||||
//TODO: const_iterator & CM_EACH missing...
|
||||
//TODO: Algorithm missing
|
||||
// nth_element, ...
|
||||
// nth_element, reduce, find_last, find_if, count_if, ...
|
||||
//TODO: Copy from a container to another if condition.
|
||||
|
||||
#define ALGOI_MAP(container, cont_oplist, func) \
|
||||
for M_EACH(item, l, cont_oplist) { \
|
||||
@@ -211,7 +212,7 @@
|
||||
|
||||
#define ALGOI_MAP_ARG(container, cont_oplist, func, ...) \
|
||||
for M_EACH(item, l, cont_oplist) { \
|
||||
func(__VA_ARGS, *item); \
|
||||
func(__VA_ARGS__, *item); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,11 @@ static void test_list(void)
|
||||
list_int_push_back (l, 17);
|
||||
assert( algo_list_count(l, 17) == 2);
|
||||
assert( algo_list_count(l, -1) == 0);
|
||||
|
||||
#define f(x) assert((x) >= 0 && (x) < 100);
|
||||
ALGO_MAP(l, LIST_OPLIST(int), f);
|
||||
#define g(y, x) assert((x) >= 0 && (x) < y);
|
||||
ALGO_MAP(l, LIST_OPLIST(int), g, 100);
|
||||
|
||||
list_int_clear(l);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user