Tag
Hash :
a78a6f18
Author :
Thomas de Grivel
Date :
2023-11-19T20:44:37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/* c3
* Copyright 2022,2023 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#ifndef COMPARE_TEST_H
#define COMPARE_TEST_H
#include "test.h"
#include "../libc3/compare.h"
#include "../libc3/str.h"
#define COMPARE_TEST_STR(a, b, expected) \
do { \
const s_str *a_ = (a); \
const s_str *b_ = (b); \
sw tmp = compare_str(a_, b_); \
if (tmp == expected) { \
g_test_assert_count++; \
g_test_assert_ok++; \
} \
else { \
test_ko(); \
fprintf(stderr, "\n%sAssertion failed in %s:%d %s\n" \
"compare_str(%s, %s) == %s\n" \
"Expected %s got %ld.%s\n", \
TEST_COLOR_KO, \
__FILE__, __LINE__, __func__, \
# a, # b, # expected, # expected, tmp, \
TEST_COLOR_RESET); \
} \
} while (0)
#endif /* COMPARE_TEST_H */