Remove array_ prefix from ARRAY_DEF

See commit on shared pointers.
This commit is contained in:
Patrick Pelissier committed 2017-07-27 22:16:15 +02:00
1 parent 4cb92a92b8
commit 34943e5b2a
14 files changed
+226 -224

No files matched your search

+14 -14
View File
@@ -3,13 +3,13 @@
#include "m-string.h"
#include "m-algo.h"
ARRAY_DEF(int, int)
ARRAY_DEF(array_int, int)
LIST_DEF(list_int, int)
LIST_DEF(list_string, string_t, STRING_OPLIST)
#include "coverage.h"
START_COVERAGE
ALGO_DEF(algo_array, ARRAY_OPLIST(int))
ALGO_DEF(algo_array, ARRAY_OPLIST(array_int))
ALGO_DEF(algo_list, LIST_OPLIST(list_int))
@@ -101,7 +101,7 @@ static void test_array(void)
assert( algo_array_count(l, -1) == 0);
assert( algo_array_sort_p(l) == false);
array_it_int_t it;
array_int_it_t it;
algo_array_find_last(it, l, 17);
assert (!array_int_end_p (it));
assert (array_int_last_p (it));
@@ -111,7 +111,7 @@ static void test_array(void)
assert (array_int_end_p (it));
#define f(x) assert((x) >= 0 && (x) < 100);
ALGO_MAP(l, ARRAY_OPLIST(int), f);
ALGO_MAP(l, ARRAY_OPLIST(array_int), f);
g_min = 0;
g_max = 99;
@@ -165,7 +165,7 @@ static void test_array(void)
array_int_clear(l);
ALGO_INIT_VA(l, ARRAY_OPLIST(int), 1, 2, 3, 4, 5);
ALGO_INIT_VA(l, ARRAY_OPLIST(array_int), 1, 2, 3, 4, 5);
assert (array_int_size(l) == 5);
array_int_clear(l);
}
@@ -206,30 +206,30 @@ static void test_extract(void)
array_int_t a;
array_int_init(a);
#define cond(d) ((d) > 0)
ALGO_EXTRACT(a, ARRAY_OPLIST(int), l, LIST_OPLIST(list_int), cond);
ALGO_EXTRACT(a, ARRAY_OPLIST(array_int), l, LIST_OPLIST(list_int), cond);
assert(array_int_size(a) == 99);
#define cond2(c, d) ((d) > (c))
ALGO_EXTRACT(a, ARRAY_OPLIST(int), l, LIST_OPLIST(list_int), cond2, 10);
ALGO_EXTRACT(a, ARRAY_OPLIST(array_int), l, LIST_OPLIST(list_int), cond2, 10);
assert(array_int_size(a) == 89);
int dst = 0;
#define inc(d, c) (d) += (c)
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), inc);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), inc);
assert (dst == 100*99/2-10*11/2);
#define sqr(d, c) (d) = (c)*(c)
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), inc, sqr);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), inc, sqr);
assert (dst == 327965);
#define sqr2(d, f, c) (d) = (f) * (c)
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), inc, sqr2, 4);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), inc, sqr2, 4);
assert (dst == (100*99/2-10*11/2) *4 );
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), sum);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), sum);
assert (dst == 100*99/2-10*11/2);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), add);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), add);
assert (dst == 100*99/2-10*11/2);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), and);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), and);
assert (dst == 0);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(int), or);
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), or);
assert (dst == 127);
array_int_clear(a);
+5 -5
View File
@@ -51,13 +51,13 @@ static void my_mpz_str(string_t str, const mpz_t z, bool append)
#include "coverage.h"
START_COVERAGE
ARRAY_DEF(uint, unsigned int)
ARRAY_DEF(mpz, mpz_t,
ARRAY_DEF(array_uint, unsigned int)
ARRAY_DEF(array_mpz, mpz_t,
(INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear), \
OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), EQUAL(my_mpz_equal_p), \
GET_STR(my_mpz_str) ))
END_COVERAGE
#define ARRAY_UINT_OPLIST ARRAY_OPLIST(uint)
#define ARRAY_UINT_OPLIST ARRAY_OPLIST(array_uint)
static void test_uint(void)
{
@@ -265,7 +265,7 @@ static void test_d(void)
for(int i = 10; i < 210; i++) {
assert (*array_uint_get (a1, i) == 0);
}
array_it_uint_t it;
array_uint_it_t it;
array_uint_it(it, a1);
array_uint_remove (a1, it);
assert (array_uint_size(a1) == 299);
@@ -276,7 +276,7 @@ static void test_d(void)
assert (array_uint_end_p(it));
array_uint_previous (it);
assert (array_uint_last_p(it));
array_it_uint_t it2;
array_uint_it_t it2;
array_uint_it_set (it2, it);
assert (array_uint_it_equal_p(it2, it));
assert (*array_uint_ref(it2) == 0);
+1 -1
View File
@@ -45,7 +45,7 @@ END_COVERAGE
DICT_SET_DEF2(setstr, string_t, STRING_OPLIST)
/* Helper structure */
ARRAY_DEF(string, string_t, STRING_OPLIST)
ARRAY_DEF(array_string, string_t, STRING_OPLIST)
array_string_t v_str;
static void init_data(int data_size)