From 70de571dc8b1af9f856a625b3456ef80d8fc6729 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Mon, 22 Jun 2020 00:14:55 +0200 Subject: [PATCH] Fix warnings in test suite. --- tests/test-marray.c | 2 +- tests/test-mbuffer.c | 4 ++-- tests/test-mgenint.c | 8 ++++---- tests/test-mrbtree.c | 2 +- tests/test-mstring.c | 28 ++++++++++++++-------------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test-marray.c b/tests/test-marray.c index c331b168..6513cd22 100644 --- a/tests/test-marray.c +++ b/tests/test-marray.c @@ -185,7 +185,7 @@ static void test_uint(void) assert (x == 1478963); assert (s == *array_uint_back(v)); - s = array_uint_size (v); + s = (unsigned int) array_uint_size (v); bool b = array_uint_erase (v, 12459); assert (b == false); assert (s == array_uint_size (v)); diff --git a/tests/test-mbuffer.c b/tests/test-mbuffer.c index 236c9c2d..f84a859e 100644 --- a/tests/test-mbuffer.c +++ b/tests/test-mbuffer.c @@ -157,7 +157,7 @@ static void test_stack(void) buffer_floats_init(buff, 100); assert (buffer_floats_capacity(buff) == 100); for(unsigned int i = 0; i < 100; i++) { - float f = i; + float f = (float) i; buffer_floats_push(buff, f); assert (buffer_floats_empty_p(buff) == false); } @@ -361,7 +361,7 @@ static void prod2(void *arg) size_t n = *p_n; size_t r = n; for(unsigned int i = 0; i < n;i++) { - while (!queue_uint_push(g_buff2, r )); + while (!queue_uint_push(g_buff2, (unsigned int) r )); r = r * 31421U + 6927U; } } diff --git a/tests/test-mgenint.c b/tests/test-mgenint.c index c4f72ead..f5925c2e 100644 --- a/tests/test-mgenint.c +++ b/tests/test-mgenint.c @@ -33,7 +33,7 @@ static void test(size_t n) genint_t s; size_t i; - genint_init(s, n); + genint_init(s, (unsigned int) n); for(int k = 0; k < 3; k++) { for(size_t j = 0; j< n ; j++) { i = genint_pop(s); @@ -44,7 +44,7 @@ static void test(size_t n) assert (genint_pop(s) == GENINT_ERROR); for(size_t j = 0; j< n ; j++) { - genint_push(s, ((j + (size_t) k) % n )); + genint_push(s, (unsigned int) ((j + (size_t) k) % n )); } } @@ -84,7 +84,7 @@ static void test2(size_t n) { m_thread_t idx[4]; - genint_init(global, n); + genint_init(global, (unsigned int) n); for(int i = 0; i < MAX_N; i++) atomic_init(&tab_g[i], false); @@ -116,7 +116,7 @@ static void test3(size_t n) m_thread_t idx[MAX_N]; assert (n <= MAX_N); - genint_init(global, n); + genint_init(global, (unsigned int) n); for(size_t i = 0; i < n; i++) { m_thread_create (idx[i], conso2, (void*)&n); } diff --git a/tests/test-mrbtree.c b/tests/test-mrbtree.c index 3b78b3af..7c18a20a 100644 --- a/tests/test-mrbtree.c +++ b/tests/test-mrbtree.c @@ -27,7 +27,7 @@ static bool uint_in_str(unsigned int *u, FILE *f) { - int n = fscanf(f, "%u", u); + int n = m_core_fscanf(f, "%u", u); return n == 1; } diff --git a/tests/test-mstring.c b/tests/test-mstring.c index 6d1d5c0b..c641e812 100644 --- a/tests/test-mstring.c +++ b/tests/test-mstring.c @@ -301,11 +301,11 @@ static void test0(void) assert (string_cmp_str(s1, "Hello \"world\"") == 0); string_set_str(s1, "Hello \"world\""); - FILE *f = fopen ("a-mstring.dat", "wt"); + FILE *f = m_core_fopen ("a-mstring.dat", "wt"); assert (f != NULL); string_out_str (f, s1); fclose (f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); assert (f != NULL); b = string_in_str(s2, f); assert(b); @@ -316,11 +316,11 @@ static void test0(void) string_get_str(s2, s1, false); assert (string_cmp_str(s2, "\"\\tHell\\\\o\\n\\\"World\\\"\\r\\001\"") == 0); - f = fopen ("a-mstring.dat", "wt"); + f = m_core_fopen ("a-mstring.dat", "wt"); assert (f != NULL); string_out_str (f, s1); fclose (f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); assert (f != NULL); b = string_in_str(s2, f); assert(b); @@ -392,11 +392,11 @@ static void test0(void) string_printf (s1, "Hello %d worlds. How do you do? I'm fine. Thank you! The weather is bad today. I should had brought my umbrella. Oh! You can lend me one! Thank you very much! No really thank you. I wouldn't be able to get in time for my job.", 2); assert (string_equal_str_p(s1, "Hello 2 worlds. How do you do? I'm fine. Thank you! The weather is bad today. I should had brought my umbrella. Oh! You can lend me one! Thank you very much! No really thank you. I wouldn't be able to get in time for my job.")); - f = fopen ("a-mstring.dat", "wt"); + f = m_core_fopen ("a-mstring.dat", "wt"); assert (f != NULL); string_fputs (f, s1); fclose (f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); assert (f != NULL); string_fgets(s2, f, STRING_READ_FILE); fclose(f); @@ -406,12 +406,12 @@ static void test0(void) string_init(s2); string_set_str(s2, "I'm ok"); - f = fopen ("a-mstring.dat", "wt"); + f = m_core_fopen ("a-mstring.dat", "wt"); assert (f != NULL); string_fputs (f, s1); fprintf (f, "\n"); fclose (f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); assert (f != NULL); string_fgets(s2, f, STRING_READ_PURE_LINE); fclose(f); @@ -419,11 +419,11 @@ static void test0(void) string_clear(s1); string_init(s1); - f = fopen("a-mstring.dat", "wt"); + f = m_core_fopen("a-mstring.dat", "wt"); assert(f != NULL); fprintf(f, "hello world...\n\tHowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww do you do?"); fclose(f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); b = string_fget_word(s1, " \t.\n?", f); assert(b); assert(string_equal_str_p(s1, "hello")); @@ -446,11 +446,11 @@ static void test0(void) assert(b == false); fclose(f); - f = fopen("a-mstring.dat", "wt"); + f = m_core_fopen("a-mstring.dat", "wt"); assert(f != NULL); fprintf(f, "word"); fclose(f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); b = string_fget_word(s1, " \t.\n?", f); assert(b); assert(string_equal_str_p(s1, "word")); @@ -549,11 +549,11 @@ static void test_bounded_io(void) string16_init(d); string16_set_str(s, "Hello \"world\""); - f = fopen ("a-mstring.dat", "wt"); + f = m_core_fopen ("a-mstring.dat", "wt"); assert (f != NULL); string16_out_str (f, s); fclose (f); - f = fopen("a-mstring.dat", "rt"); + f = m_core_fopen("a-mstring.dat", "rt"); assert (f != NULL); b = string16_in_str(d, f); assert(b);