From e9f603fa300743144e50c82bc5ec973c10142eca Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Tue, 8 May 2018 10:40:29 +0200 Subject: [PATCH] Rename internal calls to my_mpz* to testobj* --- tests/test-marray.c | 14 +++---- tests/test-mbptree.c | 16 ++++---- tests/test-mbuffer.c | 2 +- tests/test-mcore.c | 4 +- tests/test-mdeque.c | 2 +- tests/test-mdict.c | 2 +- tests/test-mlist.c | 34 ++++++++--------- tests/test-mprioqueue.c | 2 +- tests/test-mrbtree.c | 2 +- tests/test-mshared.c | 14 +++---- tests/test-msnapshot.c | 2 +- tests/test-mtuple.c | 24 ++++++------ tests/test-mvariant.c | 12 +++--- tests/test-obj.h | 82 +++++++++++++++++++++++------------------ 14 files changed, 112 insertions(+), 100 deletions(-) diff --git a/tests/test-marray.c b/tests/test-marray.c index edbdc824..b84b10d0 100644 --- a/tests/test-marray.c +++ b/tests/test-marray.c @@ -27,7 +27,7 @@ START_COVERAGE ARRAY_DEF(array_uint, unsigned int) -ARRAY_DEF(array_mpz, my_mpz_t, MY_MPZ_OPLIST) +ARRAY_DEF(array_mpz, testobj_t, TESTOBJ_OPLIST) END_COVERAGE #define ARRAY_UINT_OPLIST ARRAY_OPLIST(array_uint) @@ -170,11 +170,11 @@ static void test_uint(void) static void test_mpz(void) { array_mpz_t array1, array2; - my_mpz_t z; + testobj_t z; array_mpz_init (array1); array_mpz_init (array2); - my_mpz_init (z); + testobj_init (z); // Test empty FILE *f = fopen ("a-marray.dat", "wt"); @@ -191,7 +191,7 @@ static void test_mpz(void) // Test non empty for(int n = 0; n < 1000; n++) { - my_mpz_set_ui (z, n); + testobj_set_ui (z, n); array_mpz_push_back (array1, z); } @@ -218,7 +218,7 @@ static void test_mpz(void) assert(*sp == 0); assert(array_mpz_equal_p(array1, array2)); - my_mpz_set_ui (z, 17); + testobj_set_ui (z, 17); array_mpz_push_back (array1, z); array_mpz_get_str(str, array1, false); assert (string_cmp_str (str, "[17]") == 0); @@ -227,7 +227,7 @@ static void test_mpz(void) assert(*sp == 0); assert(array_mpz_equal_p(array1, array2)); - my_mpz_set_ui (z, 42); + testobj_set_ui (z, 42); array_mpz_push_back (array1, z); array_mpz_get_str(str, array1, true); assert (string_cmp_str (str, "[17][17,42]") == 0); @@ -242,7 +242,7 @@ static void test_mpz(void) // NOTE: Not the same order than list... } - my_mpz_clear (z); + testobj_clear (z); array_mpz_clear(array2); array_mpz_clear(array1); } diff --git a/tests/test-mbptree.c b/tests/test-mbptree.c index 1c6f5f13..8ff95f29 100644 --- a/tests/test-mbptree.c +++ b/tests/test-mbptree.c @@ -30,10 +30,10 @@ START_COVERAGE BPTREE_DEF2(btree, 3, int, M_DEFAULT_OPLIST, int, M_DEFAULT_OPLIST) END_COVERAGE -BPTREE_DEF2(btree_my, 3, my_mpz_t, MY_MPZ_CMP_OPLIST, my_mpz_t, MY_MPZ_CMP_OPLIST) +BPTREE_DEF2(btree_my, 3, testobj_t, TESTOBJ_CMP_OPLIST, testobj_t, TESTOBJ_CMP_OPLIST) BPTREE_DEF(btree_intset, 13, int) -BPTREE_DEF(btree_myset, 15, my_mpz_t, MY_MPZ_CMP_OPLIST) +BPTREE_DEF(btree_myset, 15, testobj_t, TESTOBJ_CMP_OPLIST) static void test1(void) { @@ -308,9 +308,9 @@ static void test5(void) static void test_io(void) { - M_LET(mpz1, mpz2, MY_MPZ_CMP_OPLIST) + M_LET(mpz1, mpz2, TESTOBJ_CMP_OPLIST) M_LET(str, STRING_OPLIST) - M_LET(tree1, tree2, BPTREE_OPLIST2(btree_my, MY_MPZ_CMP_OPLIST, MY_MPZ_CMP_OPLIST)) { + M_LET(tree1, tree2, BPTREE_OPLIST2(btree_my, TESTOBJ_CMP_OPLIST, TESTOBJ_CMP_OPLIST)) { btree_my_get_str(str, tree1, false); assert(string_equal_str_p(str, "{}")); const char *endp; @@ -331,11 +331,11 @@ static void test_io(void) assert (btree_my_equal_p (tree1, tree2)); fclose(f); - my_mpz_set_ui(mpz1, 67); - my_mpz_set_ui(mpz2, 670); + testobj_set_ui(mpz1, 67); + testobj_set_ui(mpz2, 670); btree_my_set_at(tree1, mpz1, mpz2); - my_mpz_set_ui(mpz1, 17); - my_mpz_set_ui(mpz2, 170); + testobj_set_ui(mpz1, 17); + testobj_set_ui(mpz2, 170); btree_my_set_at(tree1, mpz1, mpz2); btree_my_get_str(str, tree1, false); diff --git a/tests/test-mbuffer.c b/tests/test-mbuffer.c index 2701d418..b0a7721a 100644 --- a/tests/test-mbuffer.c +++ b/tests/test-mbuffer.c @@ -41,7 +41,7 @@ BUFFER_DEF(buffer_char, char, 10, BUFFER_STACK|BUFFER_UNBLOCKING) BUFFER_DEF(buffer_llong, long long, 16, BUFFER_QUEUE|BUFFER_THREAD_UNSAFE|BUFFER_UNBLOCKING) // Define a buffer of complex structure. -BUFFER_DEF(buffer_mpz, my_mpz_t, 32, BUFFER_QUEUE, MY_MPZ_OPLIST) +BUFFER_DEF(buffer_mpz, testobj_t, 32, BUFFER_QUEUE, TESTOBJ_OPLIST) buffer_uint_t g_buff; diff --git a/tests/test-mcore.c b/tests/test-mcore.c index 53aea41e..9dc415d7 100644 --- a/tests/test-mcore.c +++ b/tests/test-mcore.c @@ -158,8 +158,8 @@ static void test_map(void) static void test_let(void) { - M_LET(z, M_CLASSIC_OPLIST(my_mpz)) { - my_mpz_add(z,z,z); + M_LET(z, M_CLASSIC_OPLIST(testobj)) { + testobj_add(z,z,z); } } diff --git a/tests/test-mdeque.c b/tests/test-mdeque.c index 9a331771..b404a757 100644 --- a/tests/test-mdeque.c +++ b/tests/test-mdeque.c @@ -31,7 +31,7 @@ START_COVERAGE DEQUE_DEF(deque, int) END_COVERAGE -DEQUE_DEF(deque_mpz, my_mpz_t, MY_MPZ_OPLIST) +DEQUE_DEF(deque_mpz, testobj_t, TESTOBJ_OPLIST) #define OPL DEQUE_OPLIST(deque) diff --git a/tests/test-mdict.c b/tests/test-mdict.c index 4db77b56..9baf0c09 100644 --- a/tests/test-mdict.c +++ b/tests/test-mdict.c @@ -39,7 +39,7 @@ END_COVERAGE DICT_STOREHASH_DEF2(dict_str2, string_t, STRING_OPLIST, string_t, STRING_OPLIST) DICT_SET_DEF2(dict_setstr, string_t, STRING_OPLIST) DICT_DEF2(dict_int, int, M_DEFAULT_OPLIST, int, M_DEFAULT_OPLIST) -DICT_DEF2(dict_mpz, string_t, STRING_OPLIST, my_mpz_t, MY_MPZ_OPLIST) +DICT_DEF2(dict_mpz, string_t, STRING_OPLIST, testobj_t, TESTOBJ_OPLIST) /* Helper structure */ ARRAY_DEF(array_string, string_t, STRING_OPLIST) diff --git a/tests/test-mlist.c b/tests/test-mlist.c index 5d907a9f..7cecec4e 100644 --- a/tests/test-mlist.c +++ b/tests/test-mlist.c @@ -28,10 +28,10 @@ #include "coverage.h" START_COVERAGE LIST_DEF(list_uint, unsigned int) -LIST_DEF(list_mpz, my_mpz_t, MY_MPZ_OPLIST) +LIST_DEF(list_mpz, testobj_t, TESTOBJ_OPLIST) LIST_DUAL_PUSH_DEF(list2_double, double) END_COVERAGE -LIST_DUAL_PUSH_DEF(list2_mpz, my_mpz_t, MY_MPZ_OPLIST) +LIST_DUAL_PUSH_DEF(list2_mpz, testobj_t, TESTOBJ_OPLIST) #define LIST_UINT_OPLIST LIST_OPLIST(list_uint) static void test_uint(void) @@ -188,36 +188,36 @@ static void test_uint(void) static void test_mpz(void) { list_mpz_t v; - my_mpz_t z, x, s; + testobj_t z, x, s; - my_mpz_init (z); - my_mpz_init (x); - my_mpz_init (s); + testobj_init (z); + testobj_init (x); + testobj_init (s); list_mpz_init(v); assert (list_mpz_empty_p(v) == true); - my_mpz_set_ui (z, 2); + testobj_set_ui (z, 2); list_mpz_push_back(v, z); assert (list_mpz_empty_p(v) == false); list_mpz_pop_back(&x, v); - assert( my_mpz_equal_p (x, z)); + assert( testobj_equal_p (x, z)); assert (list_mpz_empty_p(v) == true); assert (list_mpz_size(v) == 0); for(unsigned int i = 0; i < 1000; i ++) { - my_mpz_set_ui (z, i); + testobj_set_ui (z, i); list_mpz_push_back(v, z); } assert (list_mpz_size(v) == 1000); list_mpz_it_t u; - my_mpz_set_ui (s, 0); + testobj_set_ui (s, 0); for(list_mpz_it(u, v); !list_mpz_end_p(u); list_mpz_next(u)) { - my_mpz_add (s, s, *list_mpz_cref(u)); + testobj_add (s, s, *list_mpz_cref(u)); } - assert (my_mpz_get_ui(s) == 1000*999/2); + assert (testobj_get_ui(s) == 1000*999/2); FILE *f = fopen ("a-mlist.dat", "wt"); if (!f) abort(); @@ -244,7 +244,7 @@ static void test_mpz(void) assert(*sp == 0); assert(list_mpz_equal_p(v, list2)); - my_mpz_set_ui (z, 17); + testobj_set_ui (z, 17); list_mpz_push_back (v, z); list_mpz_get_str(str, v, false); assert (string_cmp_str (str, "[17]") == 0); @@ -253,7 +253,7 @@ static void test_mpz(void) assert(*sp == 0); assert(list_mpz_equal_p(v, list2)); - my_mpz_set_ui (z, 42); + testobj_set_ui (z, 42); list_mpz_push_back (v, z); list_mpz_get_str(str, v, true); assert (string_cmp_str (str, "[17][42,17]") == 0); @@ -270,9 +270,9 @@ static void test_mpz(void) list_mpz_clear(v); list_mpz_clear(list2); - my_mpz_clear (z); - my_mpz_clear (x); - my_mpz_clear (s); + testobj_clear (z); + testobj_clear (x); + testobj_clear (s); } static void test_dual_push1(void) diff --git a/tests/test-mprioqueue.c b/tests/test-mprioqueue.c index ce499f4c..0d4690ba 100644 --- a/tests/test-mprioqueue.c +++ b/tests/test-mprioqueue.c @@ -29,7 +29,7 @@ START_COVERAGE PRIOQUEUE_DEF(int_pqueue, int) END_COVERAGE -PRIOQUEUE_DEF(mpz_pqueue, my_mpz_t, MY_MPZ_CMP_OPLIST) +PRIOQUEUE_DEF(mpz_pqueue, testobj_t, TESTOBJ_CMP_OPLIST) static void test1(void) { diff --git a/tests/test-mrbtree.c b/tests/test-mrbtree.c index b010fab9..296c41f0 100644 --- a/tests/test-mrbtree.c +++ b/tests/test-mrbtree.c @@ -55,7 +55,7 @@ RBTREE_DEF(rbtree_uint, unsigned int, M_OPEXTEND(M_DEFAULT_OPLIST, IN_STR(uint_i END_COVERAGE RBTREE_DEF(rbtree_float, float) -RBTREE_DEF(rbtree_mpz, my_mpz_t, MY_MPZ_OPLIST) +RBTREE_DEF(rbtree_mpz, testobj_t, TESTOBJ_OPLIST) #define UINT_OPLIST RBTREE_OPLIST(rbtree_uint) #define FLOAT_OP RBTREE_OPLIST(rbtree_float) diff --git a/tests/test-mshared.c b/tests/test-mshared.c index 9fa4043d..5825f170 100644 --- a/tests/test-mshared.c +++ b/tests/test-mshared.c @@ -28,9 +28,9 @@ #include "coverage.h" START_COVERAGE SHARED_PTR_DEF(shared_int, int) -SHARED_RESOURCE_DEF(shared_ressource, my_mpz_t, M_CLASSIC_OPLIST(my_mpz)) +SHARED_RESOURCE_DEF(shared_ressource, testobj_t, TESTOBJ_OPLIST) END_COVERAGE -SHARED_PTR_DEF(shared_mpz, my_mpz_t, M_CLASSIC_OPLIST(my_mpz)) +SHARED_PTR_DEF(shared_mpz, testobj_t, TESTOBJ_OPLIST) SHARED_PTR_RELAXED_DEF(shared_relaxed_int, int) static int f(const shared_int_t p) @@ -143,18 +143,18 @@ static void test_ressource(int n) for(int i = 0; i < n ; i++) { shared_ressource_it (it[i], ressource); assert (!shared_ressource_end_p(it[i])); - my_mpz_t *z = shared_ressource_ref(it[i]); + testobj_t *z = shared_ressource_ref(it[i]); assert (z != NULL); - my_mpz_set_ui(*z, i); + testobj_set_ui(*z, i); } shared_ressource_it (onemore, ressource); assert (shared_ressource_end_p(onemore)); for(int i = 0; i < n ; i++) { shared_ressource_it_set (copy[i], it[i]); assert (!shared_ressource_end_p(copy[i])); - const my_mpz_t *z = shared_ressource_cref(copy[i]); + const testobj_t *z = shared_ressource_cref(copy[i]); assert (z != NULL); - assert (my_mpz_cmp_ui(*z, i) == 0); + assert (testobj_cmp_ui(*z, i) == 0); } shared_ressource_it (onemore, ressource); assert (shared_ressource_end_p(onemore)); @@ -164,7 +164,7 @@ static void test_ressource(int n) shared_ressource_it (onemore, ressource); assert (shared_ressource_end_p(onemore)); for(int i = n-1; i >= 0 ; i--) { - const my_mpz_t *z = shared_ressource_cref(copy[i]); + const testobj_t *z = shared_ressource_cref(copy[i]); assert (z != NULL); shared_ressource_end (copy[i], ressource); assert (shared_ressource_end_p(copy[i])); diff --git a/tests/test-msnapshot.c b/tests/test-msnapshot.c index 42200978..6ae7815c 100644 --- a/tests/test-msnapshot.c +++ b/tests/test-msnapshot.c @@ -47,7 +47,7 @@ static void data_set(data_t *p, data_t o) { p->n = o.n; data_crc(p); } START_COVERAGE SNAPSHOT_SPSC_DEF(snapshot_uint, unsigned int) -SNAPSHOT_SPSC_DEF(snapshot_mpz, my_mpz_t, MY_MPZ_OPLIST) +SNAPSHOT_SPSC_DEF(snapshot_mpz, testobj_t, TESTOBJ_OPLIST) SNAPSHOT_SPMC_DEF(snapshot_mrsw_data, data_t, DATA_OPLIST) SNAPSHOT_MPMC_DEF(snapshot_mrmw_data, data_t, DATA_OPLIST) END_COVERAGE diff --git a/tests/test-mtuple.c b/tests/test-mtuple.c index 4dbf4b07..b3207fc7 100644 --- a/tests/test-mtuple.c +++ b/tests/test-mtuple.c @@ -30,19 +30,19 @@ START_COVERAGE TUPLE_DEF2(pair, (key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear))), - (value, my_mpz_t, MY_MPZ_OPLIST) ) + (value, testobj_t, TESTOBJ_OPLIST) ) END_COVERAGE // No cmp defined TUPLE_DEF2(triple, (key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear), CMP(string_cmp))), - (value, my_mpz_t, MY_MPZ_OPLIST ), + (value, testobj_t, TESTOBJ_OPLIST ), (data, const char *, ())) // cmp shall be defined TUPLE_DEF2(pair3, (key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear), CMP(string_cmp), HASH(string_hash), EQUAL(string_equal_p))), - (value, my_mpz_t, M_OPEXTEND( MY_MPZ_OPLIST, CMP(my_mpz_cmp)) ) ) + (value, testobj_t, M_OPEXTEND( TESTOBJ_OPLIST, CMP(testobj_cmp)) ) ) TUPLE_DEF2(pair_str, (vala, string_t, STRING_OPLIST), @@ -103,24 +103,24 @@ int main(void) pair_init (p1); string_set_str(p1->key, "HELLO"); - my_mpz_set_ui(p1->value, 1742); + testobj_set_ui(p1->value, 1742); pair_init_set (p2, p1); - assert(my_mpz_cmp_ui(p2->value, 1742) == 0); + assert(testobj_cmp_ui(p2->value, 1742) == 0); assert(string_equal_str_p(p2->key, "HELLO")); string_set_str(p2->key, "HELLO WORLD"); - my_mpz_set_ui(p2->value, 174217); + testobj_set_ui(p2->value, 174217); pair_set(p1, p1); pair_set(p1, p2); - assert(my_mpz_cmp_ui(p1->value, 174217) == 0); + assert(testobj_cmp_ui(p1->value, 174217) == 0); assert(string_equal_str_p(p1->key, "HELLO WORLD")); pair_clear(p1); pair_clear(p2); string_t s; - my_mpz_t z; + testobj_t z; pair3_t p3, p4; string_init_set_str(s, "HELLO"); - my_mpz_init_set_ui (z, 1442); + testobj_init_set_ui (z, 1442); pair3_init_set2(p3, s, z); pair3_init_set2(p4, s, z); int i = pair3_cmp (p3, p4); @@ -128,11 +128,11 @@ int main(void) pair3_set2(p4, s, z); i = pair3_cmp (p3, p4); assert (i == 0); - my_mpz_set_ui (z, 1443); + testobj_set_ui (z, 1443); pair3_set_value(p4, z); i = pair3_cmp (p3, p4); assert (i < 0); - my_mpz_set_ui (z, 1442); + testobj_set_ui (z, 1442); string_set_str(s, "HELLN"); pair3_set_key(p4, s); i = pair3_cmp (p3, p4); @@ -140,7 +140,7 @@ int main(void) pair3_clear(p3); pair3_clear(p4); string_clear(s); - my_mpz_clear(z); + testobj_clear(z); check_io(); check_swap(); diff --git a/tests/test-mvariant.c b/tests/test-mvariant.c index ab0e0b8d..78243108 100644 --- a/tests/test-mvariant.c +++ b/tests/test-mvariant.c @@ -150,7 +150,7 @@ static void test_pair(void) VARIANT_DEF2(triple, (s, string_t, STRING_OPLIST), - (z, my_mpz_t, (INIT(my_mpz_init), INIT_SET(my_mpz_init_set), SET(my_mpz_set), CLEAR(my_mpz_clear) )), + (z, testobj_t, (INIT(testobj_init), INIT_SET(testobj_init_set), SET(testobj_set), CLEAR(testobj_clear) )), (i, int, M_DEFAULT_OPLIST) ) static void @@ -160,10 +160,10 @@ test_triple(void) triple_init(t); string_t s; string_init(s); - my_mpz_t z; - my_mpz_init(z); + testobj_t z; + testobj_init(z); - my_mpz_set_ui(z, 2556789045); + testobj_set_ui(z, 2556789045); string_set_str(s, "FHZKJHFKZUHFKZHFUHZFUHURHYERUYEUIRYEIURYIEYRIU"); assert( triple_type(t) == triple_EMPTY); @@ -177,9 +177,9 @@ test_triple(void) assert( triple_type(t) == triple_z); triple_set_z(t, z); assert( triple_type(t) == triple_z); - assert( my_mpz_cmp (z, *triple_get_z(t)) == 0); + assert( testobj_cmp (z, *triple_get_z(t)) == 0); - my_mpz_clear(z); + testobj_clear(z); string_clear(s); triple_clear(t); } diff --git a/tests/test-obj.h b/tests/test-obj.h index fdd34fd9..89cf4777 100644 --- a/tests/test-obj.h +++ b/tests/test-obj.h @@ -1,17 +1,17 @@ -#ifndef MY_MPZ_T -#define MY_MPZ_T +#ifndef TESTOBJ_T +#define TESTOBJ_T #include "m-string.h" /* This is a trivial encapsulation of an opaque structure. Used for test purpose only.*/ -typedef struct my_mpz_s { +typedef struct testobj_s { unsigned int n; unsigned int a; unsigned int *ptr; -} my_mpz_t[1]; +} testobj_t[1]; -static void my_mpz_init(my_mpz_t z) +static void testobj_init(testobj_t z) { z->n = 1; z->a = 1; @@ -19,13 +19,13 @@ static void my_mpz_init(my_mpz_t z) if (!z->ptr) abort(); } -static void my_mpz_clear(my_mpz_t z) +static void testobj_clear(testobj_t z) { free(z->ptr); z->ptr = NULL; } -static void my_mpz_init_set(my_mpz_t d, const my_mpz_t s) +static void testobj_init_set(testobj_t d, const testobj_t s) { d->n = s->n; d->a = s->n; @@ -33,47 +33,47 @@ static void my_mpz_init_set(my_mpz_t d, const my_mpz_t s) memcpy(d->ptr, s->ptr, sizeof(unsigned int) * s->n); } -static void my_mpz_set(my_mpz_t d, const my_mpz_t s) +static void testobj_set(testobj_t d, const testobj_t s) { - my_mpz_clear(d); - my_mpz_init_set(d, s); + testobj_clear(d); + testobj_init_set(d, s); } -static void my_mpz_set_ui(my_mpz_t d, unsigned int v) +static void testobj_set_ui(testobj_t d, unsigned int v) { d->n = 1; d->ptr[0] = v; } -static void my_mpz_init_set_ui(my_mpz_t d, unsigned int v) +static void testobj_init_set_ui(testobj_t d, unsigned int v) { - my_mpz_init(d); - my_mpz_set_ui(d, v); + testobj_init(d); + testobj_set_ui(d, v); } -static unsigned int my_mpz_get_ui(const my_mpz_t z) +static unsigned int testobj_get_ui(const testobj_t z) { return z->ptr[0]; } -static void my_mpz_add(my_mpz_t d, const my_mpz_t a, const my_mpz_t b) +static void testobj_add(testobj_t d, const testobj_t a, const testobj_t b) { d->ptr[0] = a->ptr[0] + b->ptr[0]; } -static void my_mpz_out_str(FILE *f, const my_mpz_t z) +static void testobj_out_str(FILE *f, const testobj_t z) { assert(z->n == 1); fprintf(f, "%u", z->ptr[0]); } -static bool my_mpz_in_str(my_mpz_t z, FILE *f) +static bool testobj_in_str(testobj_t z, FILE *f) { z->n = 1; return fscanf(f, "%u", &z->ptr[0]) == 1; } -static bool my_mpz_parse_str(my_mpz_t z, const char str[], const char **endptr) +static bool testobj_parse_str(testobj_t z, const char str[], const char **endptr) { z->n = 1; char *end; @@ -82,43 +82,55 @@ static bool my_mpz_parse_str(my_mpz_t z, const char str[], const char **endptr) return (uintptr_t) end != (uintptr_t) str; } -static bool my_mpz_equal_p(const my_mpz_t z1, const my_mpz_t z2) +static bool testobj_equal_p(const testobj_t z1, const testobj_t z2) { if (z1->n != z2->n) return false; return memcmp(z1->ptr, z2->ptr, z1->n*sizeof(unsigned int)) == 0; } -static int my_mpz_cmp(const my_mpz_t z1, const my_mpz_t z2) +static int testobj_cmp(const testobj_t z1, const testobj_t z2) { if (z1->n != z2->n) return z1-> n < z2->n ? -1 : 1; return memcmp(z1->ptr, z2->ptr, z1->n*sizeof(unsigned int)); } -static int my_mpz_cmp_ui(const my_mpz_t z1, unsigned int z2) +static int testobj_cmp_ui(const testobj_t z1, unsigned int z2) { if (z1->n != 1) return z1-> n < 1 ? -1 : 1; return memcmp(z1->ptr, &z2, sizeof(unsigned int)); } -static void my_mpz_str(string_t str, const my_mpz_t z, bool append) +static void testobj_str(string_t str, const testobj_t z, bool append) { if (append) string_cat_printf (str, "%u", z->ptr[0]); else string_printf (str, "%u", z->ptr[0]); } -#define MY_MPZ_OPLIST \ - (INIT(my_mpz_init), INIT_SET(my_mpz_init_set), SET(my_mpz_set), CLEAR(my_mpz_clear), \ - TYPE(my_mpz_t), \ - OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), \ - PARSE_STR(my_mpz_parse_str), GET_STR(my_mpz_str), \ - EQUAL(my_mpz_equal_p), \ +#define TESTOBJ_OPLIST \ + (INIT(testobj_init), \ + INIT_SET(testobj_init_set), \ + SET(testobj_set), \ + CLEAR(testobj_clear), \ + TYPE(testobj_t), \ + OUT_STR(testobj_out_str), \ + IN_STR(testobj_in_str), \ + PARSE_STR(testobj_parse_str), \ + GET_STR(testobj_str), \ + EQUAL(testobj_equal_p), \ ) -#define MY_MPZ_CMP_OPLIST \ - (INIT(my_mpz_init), INIT_SET(my_mpz_init_set), SET(my_mpz_set), CLEAR(my_mpz_clear), \ - TYPE(my_mpz_t), \ - OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), \ - PARSE_STR(my_mpz_parse_str), GET_STR(my_mpz_str), \ - EQUAL(my_mpz_equal_p), CMP(my_mpz_cmp) ) +#define TESTOBJ_CMP_OPLIST \ + (INIT(testobj_init), \ + INIT_SET(testobj_init_set), \ + SET(testobj_set), \ + CLEAR(testobj_clear), \ + TYPE(testobj_t), \ + OUT_STR(testobj_out_str), \ + IN_STR(testobj_in_str), \ + PARSE_STR(testobj_parse_str), \ + GET_STR(testobj_str), \ + EQUAL(testobj_equal_p), \ + CMP(testobj_cmp) \ + ) #endif