diff --git a/tests/test-marray.c b/tests/test-marray.c index d3a5f25c..3a72a8b4 100644 --- a/tests/test-marray.c +++ b/tests/test-marray.c @@ -245,6 +245,67 @@ static void test_mpz(void) assert (array_mpz_equal_p (array1, array2)); fclose(f); + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "array"); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == false); + fclose(f); + + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "["); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == false); + fclose(f); + + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17"); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == false); + fclose(f); + + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17,"); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == false); + fclose(f); + + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17,18"); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == false); + fclose(f); + + f = m_core_fopen ("a-marray.dat", "wt"); + if (!f) abort(); + fprintf(f, "[]"); + fclose (f); + f = m_core_fopen ("a-marray.dat", "rt"); + if (!f) abort(); + b = array_mpz_in_str (array2, f); + assert (b == true); + fclose(f); + assert(array_mpz_empty_p(array2)); + array_mpz_reset(array1); M_LET(str, STRING_OPLIST) { @@ -278,6 +339,12 @@ static void test_mpz(void) assert(strcmp(sp, "") == 0); assert(array_mpz_equal_p(array1, array2)); + array_mpz_push_back(array1, z); + assert(!array_mpz_equal_p(array1, array2)); + testobj_set_ui (z, 43); + array_mpz_push_back(array2, z); + assert(!array_mpz_equal_p(array1, array2)); + b = array_mpz_parse_str(array2, "[", &sp); assert(!b); b = array_mpz_parse_str(array2, "[17,", &sp); @@ -408,6 +475,10 @@ static void test_d(void) array_uint_init_set (a2, a1); assert (array_uint_equal_p (a2, a1)); + array_uint_push_back(a2, 890); + assert (!array_uint_equal_p (a2, a1)); + array_uint_push_back(a1, 891); + assert (!array_uint_equal_p (a2, a1)); size_t h = array_uint_hash(a2); assert (h != 0); diff --git a/tests/test-mbitset.c b/tests/test-mbitset.c index 8973a594..cf3ad3fa 100644 --- a/tests/test-mbitset.c +++ b/tests/test-mbitset.c @@ -380,6 +380,8 @@ static void test_clz(void) } M_LET(s1, bitset_t) { + bitset_reset(s1); + assert(bitset_ctz(s1) == 0); bitset_set_str(s1, "[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]"); assert(bitset_ctz(s1) == 116); bitset_set_str(s1, "[10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]"); diff --git a/tests/test-milist.c b/tests/test-milist.c index 7e22bbf6..f8e6e487 100644 --- a/tests/test-milist.c +++ b/tests/test-milist.c @@ -120,12 +120,7 @@ static void test(void) assert (ilist_tname_size(list) == 0); assert (ilist_tname_empty_p(list)); - for M_EACH(item, list, ILIST_OPLIST(ilist_tname)) { - (void)item; - if (M_UNLIKELY_NOMEM(1)) { - assert(false); - } - } + for M_EACH(item, list, ILIST_OPLIST(ilist_tname)) ( (void)item, assert(false) ); ilist_tname_push_back (list, &x3); assert (ilist_tname_size (list) == 1); diff --git a/tests/test-mlist.c b/tests/test-mlist.c index d5eafbd1..ff21caf7 100644 --- a/tests/test-mlist.c +++ b/tests/test-mlist.c @@ -314,6 +314,73 @@ static void test_mpz(void) assert (list_mpz_equal_p (v, list2)); list_mpz_clear(list2); + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "["); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == false); + fclose(f); + list_mpz_clear(list2); + + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17"); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == false); + fclose(f); + list_mpz_clear(list2); + + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17,"); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == false); + fclose(f); + list_mpz_clear(list2); + + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "[17,18"); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == false); + fclose(f); + list_mpz_clear(list2); + + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "]"); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == false); + fclose(f); + list_mpz_clear(list2); + + f = m_core_fopen ("a-mlist.dat", "wt"); + if (!f) abort(); + fprintf(f, "[]"); + fclose (f); + list_mpz_init(list2); + f = m_core_fopen ("a-mlist.dat", "rt"); + b = list_mpz_in_str (list2, f); + assert (b == true); + fclose(f); + assert(list_mpz_empty_p(list2)); + list_mpz_clear(list2); + list_mpz_reset(v); list_mpz_init(list2); M_LET(str, STRING_OPLIST) { @@ -346,6 +413,20 @@ static void test_mpz(void) assert(b); assert(strcmp(sp, "") == 0); assert(list_mpz_equal_p(v, list2)); + assert(list_mpz_equal_p(v, v)); + assert(list_mpz_equal_p(list2, list2)); + + b = list_mpz_parse_str(list2, "[17,18", &sp); + assert(!b); + + b = list_mpz_parse_str(list2, "[17,", &sp); + assert(!b); + + b = list_mpz_parse_str(list2, "[17", &sp); + assert(!b); + + b = list_mpz_parse_str(list2, "[", &sp); + assert(!b); } list_mpz_clear(v); @@ -469,6 +550,10 @@ static void test_dual_push1(void) } list2_double_init_set (list2, list); assert(list2_double_equal_p(list, list2)); + assert(list2_double_equal_p(list, list)); + list2_double_push_back(list, 17.0); + assert(!list2_double_equal_p(list, list2)); + list2_double_pop_back(NULL, list); list2_double_reverse(list2); for(double e = 0.0; e < 1024.0 ; e += 1.0) {