Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation errors with the recent gcc #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,31 @@ setup_allocator(void)
do { \
call; \
if (cork_error_occurred()) { \
fail("%s", cork_error_message()); \
ck_abort_msg(cork_error_message()); \
} \
} while (0)

#define fail_unless_error(call, ...) \
do { \
call; \
if (!cork_error_occurred()) { \
fail(__VA_ARGS__); \
ck_abort_msg(__VA_ARGS__); \
} else { \
print_expected_failure(); \
} \
cork_error_clear(); \
} while (0)

#define fail_unless_equal(what, format, expected, actual) \
(fail_unless((expected) == (actual), \
(ck_assert_msg((expected) == (actual), \
"%s not equal (expected " format \
", got " format ")", \
(what), (expected), (actual)))

#define fail_unless_streq(what, expected, actual) \
(fail_unless(strcmp((expected), (actual)) == 0, \
(ck_assert_msg(strcmp((expected), (actual)) == 0, \
"%s not equal (expected \"%s\", got \"%s\")", \
(char *) (what), (char *) (expected), (char *) (actual)))


#define ck_assert_false_msg(expr, ...) ck_assert_msg(!(expr), ## __VA_ARGS__)
#endif /* TESTS_HELPERS_H */
8 changes: 4 additions & 4 deletions tests/test-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
*/

#define verify_size(array, expected_size) \
fail_unless(cork_array_size((array)) == expected_size, \
ck_assert_msg(cork_array_size((array)) == expected_size, \
"Unexpected size of array: got %zu, expected %zu", \
cork_array_size((array)), expected_size);
(size_t)cork_array_size((array)), (size_t)expected_size);

#define add_element(element, expected_new_size) \
fail_if_error(cork_array_append(&array, element)); \
Expand All @@ -48,7 +48,7 @@
for (i = 0; i < cork_array_size(array); i++) { \
sum += cork_array_at(array, i); \
} \
fail_unless(sum == expected, \
ck_assert_msg(sum == expected, \
"Unexpected sum, got %ld, expected %ld", \
(long) sum, (long) expected); \
} while (0)
Expand All @@ -62,7 +62,7 @@
cork_array(int_type) copy; \
cork_array_init(&array); \
\
fail_unless(cork_array_size(&array) == 0, \
ck_assert_msg(cork_array_size(&array) == 0, \
"Unexpected size of array: got %zu, expected 0", \
cork_array_size(&array)); \
\
Expand Down
8 changes: 4 additions & 4 deletions tests/test-bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ test_bitset_of_size(size_t bit_count)

for (i = 0; i < bit_count; i++) {
cork_bitset_set(set1, i, true);
fail_unless(cork_bitset_get(set1, i), "Unexpected value for bit %zu", i);
ck_assert_msg(cork_bitset_get(set1, i), "Unexpected value for bit %zu", i);
}

for (i = 0; i < bit_count; i++) {
cork_bitset_set(set1, i, false);
fail_if(cork_bitset_get(set1, i), "Unexpected value for bit %zu", i);
ck_assert_false_msg(cork_bitset_get(set1, i), "Unexpected value for bit %zu", i);
}
cork_bitset_free(set1);

cork_bitset_init(&set2, bit_count);
for (i = 0; i < bit_count; i++) {
cork_bitset_set(&set2, i, true);
fail_unless(cork_bitset_get(&set2, i), "Unexpected value for bit %zu", i);
ck_assert_msg(cork_bitset_get(&set2, i), "Unexpected value for bit %zu", i);
}

for (i = 0; i < bit_count; i++) {
cork_bitset_set(&set2, i, false);
fail_if(cork_bitset_get(&set2, i), "Unexpected value for bit %zu", i);
ck_assert_false_msg(cork_bitset_get(&set2, i), "Unexpected value for bit %zu", i);
}
cork_bitset_done(&set2);
}
Expand Down
18 changes: 9 additions & 9 deletions tests/test-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
static void
check_buffers(const struct cork_buffer *buf1, const struct cork_buffer *buf2)
{
fail_unless(cork_buffer_equal(buf1, buf2),
ck_assert_msg(cork_buffer_equal(buf1, buf2),
"Buffers should be equal: got %zu:%s, expected %zu:%s",
buf1->size, buf1->buf, buf2->size, buf2->buf);
buf1->size, (char*)buf1->buf, buf2->size, (char*)buf2->buf);
}

static void
check_buffer(const struct cork_buffer *buf, const char *expected)
{
size_t expected_len = strlen(expected);
fail_unless(buf->size == expected_len,
ck_assert_msg(buf->size == expected_len,
"Unexpected buffer content: got %zu:%s, expected %zu:%s",
buf->size, buf->buf, expected_len, expected);
buf->size, (char*)buf->buf, expected_len, expected);
}

START_TEST(test_buffer)
Expand All @@ -56,11 +56,11 @@ START_TEST(test_buffer)
cork_buffer_init(&buffer1);
fail_if_error(cork_buffer_set(&buffer1, SRC, SRC_LEN));

fail_unless(cork_buffer_char(&buffer1, 0) == 'H',
ck_assert_msg(cork_buffer_char(&buffer1, 0) == 'H',
"Unexpected character at position 0: got %c, expected %c",
(int) cork_buffer_char(&buffer1, 0), (int) 'H');

fail_unless(cork_buffer_byte(&buffer1, 1) == (uint8_t) 'e',
ck_assert_msg(cork_buffer_byte(&buffer1, 1) == (uint8_t) 'e',
"Unexpected character at position 1: got %c, expected %c",
(int) cork_buffer_byte(&buffer1, 1), (int) 'e');

Expand Down Expand Up @@ -127,9 +127,9 @@ START_TEST(test_buffer_append)
(buffer3, "%s%s%s", SRC2, SRC3, SRC4));
check_buffers(&buffer1, buffer3);

fail_unless(cork_buffer_equal(&buffer1, buffer3),
ck_assert_msg(cork_buffer_equal(&buffer1, buffer3),
"Buffers should be equal: got %zu:%s, expected %zu:%s",
buffer1.size, buffer1.buf, buffer3->size, buffer3->buf);
buffer1.size, (char*)buffer1.buf, buffer3->size, (char*)buffer3->buf);

cork_buffer_done(&buffer1);
cork_buffer_done(&buffer2);
Expand Down Expand Up @@ -176,7 +176,7 @@ START_TEST(test_buffer_slicing)
fail_if_error(cork_slice_slice_offset_fast(&slice2, 2));
fail_if_error(cork_slice_slice_fast(&slice2, 0, 2));
fail_if_error(cork_slice_slice(&slice1, 2, 2));
fail_unless(cork_slice_equal(&slice1, &slice2), "Slices should be equal");
ck_assert_msg(cork_slice_equal(&slice1, &slice2), "Slices should be equal");
cork_slice_finish(&slice2);

cork_slice_finish(&slice1);
Expand Down
Loading