Improve coverage of the test suite.

This commit is contained in:
Patrick Pelissier committed 2023-04-05 23:07:52 +02:00
1 parent 9d77448a25
commit f858aa2cb5
4 files changed
+159 -6

No files matched your search

+71
View File
@@ -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);
+2
View File
@@ -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]");
+1 -6
View File
@@ -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);
+85
View File
@@ -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) {