This commit is contained in:
Gregory Burd 2024-03-15 16:24:08 -04:00
parent b01cd70160
commit 3b1a03c86f
6 changed files with 638 additions and 373 deletions

View file

@ -1,6 +1,7 @@
CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c99 -Iinclude/ -fPIC CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c99 -Iinclude/ -fPIC
TEST_FLAGS = -Itests/ -fsanitize=address,undefined TEST_FLAGS = -Itests/
#-fsanitize=address,undefined
OBJS = skiplist.o OBJS = skiplist.o
STATIC_LIB = libskiplist.a STATIC_LIB = libskiplist.a
@ -31,6 +32,7 @@ tests/%.o: tests/%.c
test: $(TESTS) test: $(TESTS)
./tests/test ./tests/test
# env LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/test
tests/test: tests/test.o tests/munit.o $(STATIC_LIB) tests/test: tests/test.o tests/munit.o $(STATIC_LIB)
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread $(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread
@ -47,4 +49,4 @@ clean:
rm -f $(EXAMPLES) rm -f $(EXAMPLES)
format: format:
clang-format -i include/*.h src/*.c tests/*.c clang-format -i include/*.h src/*.c tests/*.c tests/*.h

View file

@ -35,12 +35,14 @@ test_api_tear_down(void *fixture)
} }
static void * static void *
test_api_insert_setup(const MunitParameter params[], void *user_data) { test_api_insert_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_insert_tear_down(void *fixture) { test_api_insert_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_insert(const MunitParameter params[], void *data) test_api_insert(const MunitParameter params[], void *data)
@ -61,12 +63,14 @@ test_api_insert(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_remove_setup(const MunitParameter params[], void *user_data) { test_api_remove_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_remove_tear_down(void *fixture) { test_api_remove_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_remove(const MunitParameter params[], void *data) test_api_remove(const MunitParameter params[], void *data)
@ -78,12 +82,14 @@ test_api_remove(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_find_setup(const MunitParameter params[], void *user_data) { test_api_find_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_find_tear_down(void *fixture) { test_api_find_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_find(const MunitParameter params[], void *data) test_api_find(const MunitParameter params[], void *data)
@ -95,12 +101,14 @@ test_api_find(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_update_setup(const MunitParameter params[], void *user_data) { test_api_update_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_update_tear_down(void *fixture) { test_api_update_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_update(const MunitParameter params[], void *data) test_api_update(const MunitParameter params[], void *data)
@ -112,12 +120,14 @@ test_api_update(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_delete_setup(const MunitParameter params[], void *user_data) { test_api_delete_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_delete_tear_down(void *fixture) { test_api_delete_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_delete(const MunitParameter params[], void *data) test_api_delete(const MunitParameter params[], void *data)
@ -129,12 +139,14 @@ test_api_delete(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_duplicates_setup(const MunitParameter params[], void *user_data) { test_api_duplicates_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_duplicates_tear_down(void *fixture) { test_api_duplicates_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_duplicates(const MunitParameter params[], void *data) test_api_duplicates(const MunitParameter params[], void *data)
@ -146,12 +158,14 @@ test_api_duplicates(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_size_setup(const MunitParameter params[], void *user_data) { test_api_size_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_size_tear_down(void *fixture) { test_api_size_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_size(const MunitParameter params[], void *data) test_api_size(const MunitParameter params[], void *data)
@ -163,12 +177,14 @@ test_api_size(const MunitParameter params[], void *data)
} }
static void * static void *
test_api_iterators_setup(const MunitParameter params[], void *user_data) { test_api_iterators_setup(const MunitParameter params[], void *user_data)
return test_api_setup(params, user_data); {
return test_api_setup(params, user_data);
} }
static void static void
test_api_iterators_tear_down(void *fixture) { test_api_iterators_tear_down(void *fixture)
test_api_tear_down(fixture); {
test_api_tear_down(fixture);
} }
static MunitResult static MunitResult
test_api_iterators(const MunitParameter params[], void *data) test_api_iterators(const MunitParameter params[], void *data)

View file

@ -1,5 +0,0 @@
static MunitTest mt_tests[] = {
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
};

View file

@ -29,92 +29,92 @@
#include <stdlib.h> #include <stdlib.h>
#define MUNIT_VERSION(major, minor, revision) \ #define MUNIT_VERSION(major, minor, revision) \
(((major) << 16) | ((minor) << 8) | (revision)) (((major) << 16) | ((minor) << 8) | (revision))
#define MUNIT_CURRENT_VERSION MUNIT_VERSION(0, 4, 1) #define MUNIT_CURRENT_VERSION MUNIT_VERSION(0, 4, 1)
#if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_MSC_VER) && (_MSC_VER < 1600)
# define munit_int8_t __int8 #define munit_int8_t __int8
# define munit_uint8_t unsigned __int8 #define munit_uint8_t unsigned __int8
# define munit_int16_t __int16 #define munit_int16_t __int16
# define munit_uint16_t unsigned __int16 #define munit_uint16_t unsigned __int16
# define munit_int32_t __int32 #define munit_int32_t __int32
# define munit_uint32_t unsigned __int32 #define munit_uint32_t unsigned __int32
# define munit_int64_t __int64 #define munit_int64_t __int64
# define munit_uint64_t unsigned __int64 #define munit_uint64_t unsigned __int64
#else #else
# include <stdint.h> #include <stdint.h>
# define munit_int8_t int8_t #define munit_int8_t int8_t
# define munit_uint8_t uint8_t #define munit_uint8_t uint8_t
# define munit_int16_t int16_t #define munit_int16_t int16_t
# define munit_uint16_t uint16_t #define munit_uint16_t uint16_t
# define munit_int32_t int32_t #define munit_int32_t int32_t
# define munit_uint32_t uint32_t #define munit_uint32_t uint32_t
# define munit_int64_t int64_t #define munit_int64_t int64_t
# define munit_uint64_t uint64_t #define munit_uint64_t uint64_t
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER < 1800) #if defined(_MSC_VER) && (_MSC_VER < 1800)
# if !defined(PRIi8) #if !defined(PRIi8)
# define PRIi8 "i" #define PRIi8 "i"
# endif #endif
# if !defined(PRIi16) #if !defined(PRIi16)
# define PRIi16 "i" #define PRIi16 "i"
# endif #endif
# if !defined(PRIi32) #if !defined(PRIi32)
# define PRIi32 "i" #define PRIi32 "i"
# endif #endif
# if !defined(PRIi64) #if !defined(PRIi64)
# define PRIi64 "I64i" #define PRIi64 "I64i"
# endif #endif
# if !defined(PRId8) #if !defined(PRId8)
# define PRId8 "d" #define PRId8 "d"
# endif #endif
# if !defined(PRId16) #if !defined(PRId16)
# define PRId16 "d" #define PRId16 "d"
# endif #endif
# if !defined(PRId32) #if !defined(PRId32)
# define PRId32 "d" #define PRId32 "d"
# endif #endif
# if !defined(PRId64) #if !defined(PRId64)
# define PRId64 "I64d" #define PRId64 "I64d"
# endif #endif
# if !defined(PRIx8) #if !defined(PRIx8)
# define PRIx8 "x" #define PRIx8 "x"
# endif #endif
# if !defined(PRIx16) #if !defined(PRIx16)
# define PRIx16 "x" #define PRIx16 "x"
# endif #endif
# if !defined(PRIx32) #if !defined(PRIx32)
# define PRIx32 "x" #define PRIx32 "x"
# endif #endif
# if !defined(PRIx64) #if !defined(PRIx64)
# define PRIx64 "I64x" #define PRIx64 "I64x"
# endif #endif
# if !defined(PRIu8) #if !defined(PRIu8)
# define PRIu8 "u" #define PRIu8 "u"
# endif #endif
# if !defined(PRIu16) #if !defined(PRIu16)
# define PRIu16 "u" #define PRIu16 "u"
# endif #endif
# if !defined(PRIu32) #if !defined(PRIu32)
# define PRIu32 "u" #define PRIu32 "u"
# endif #endif
# if !defined(PRIu64) #if !defined(PRIu64)
# define PRIu64 "I64u" #define PRIu64 "I64u"
# endif #endif
#else #else
# include <inttypes.h> #include <inttypes.h>
#endif #endif
#if !defined(munit_bool) #if !defined(munit_bool)
# if defined(bool) #if defined(bool)
# define munit_bool bool #define munit_bool bool
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define munit_bool _Bool #define munit_bool _Bool
# else #else
# define munit_bool int #define munit_bool int
# endif #endif
#endif #endif
#if defined(__cplusplus) #if defined(__cplusplus)
@ -122,275 +122,266 @@ extern "C" {
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
# define MUNIT_LIKELY(expr) (__builtin_expect ((expr), 1)) #define MUNIT_LIKELY(expr) (__builtin_expect((expr), 1))
# define MUNIT_UNLIKELY(expr) (__builtin_expect ((expr), 0)) #define MUNIT_UNLIKELY(expr) (__builtin_expect((expr), 0))
# define MUNIT_UNUSED __attribute__((__unused__)) #define MUNIT_UNUSED __attribute__((__unused__))
#else #else
# define MUNIT_LIKELY(expr) (expr) #define MUNIT_LIKELY(expr) (expr)
# define MUNIT_UNLIKELY(expr) (expr) #define MUNIT_UNLIKELY(expr) (expr)
# define MUNIT_UNUSED #define MUNIT_UNUSED
#endif #endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__PGI) #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
# define MUNIT_ARRAY_PARAM(name) name !defined(__PGI)
#define MUNIT_ARRAY_PARAM(name) name
#else #else
# define MUNIT_ARRAY_PARAM(name) #define MUNIT_ARRAY_PARAM(name)
#endif #endif
#if !defined(_WIN32) #if !defined(_WIN32)
# define MUNIT_SIZE_MODIFIER "z" #define MUNIT_SIZE_MODIFIER "z"
# define MUNIT_CHAR_MODIFIER "hh" #define MUNIT_CHAR_MODIFIER "hh"
# define MUNIT_SHORT_MODIFIER "h" #define MUNIT_SHORT_MODIFIER "h"
#else #else
# if defined(_M_X64) || defined(__amd64__) #if defined(_M_X64) || defined(__amd64__)
# define MUNIT_SIZE_MODIFIER "I64" #define MUNIT_SIZE_MODIFIER "I64"
# else #else
# define MUNIT_SIZE_MODIFIER "" #define MUNIT_SIZE_MODIFIER ""
# endif #endif
# define MUNIT_CHAR_MODIFIER "" #define MUNIT_CHAR_MODIFIER ""
# define MUNIT_SHORT_MODIFIER "" #define MUNIT_SHORT_MODIFIER ""
#endif #endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
# define MUNIT_NO_RETURN _Noreturn #define MUNIT_NO_RETURN _Noreturn
#elif defined(__GNUC__) #elif defined(__GNUC__)
# define MUNIT_NO_RETURN __attribute__((__noreturn__)) #define MUNIT_NO_RETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define MUNIT_NO_RETURN __declspec(noreturn) #define MUNIT_NO_RETURN __declspec(noreturn)
#else #else
# define MUNIT_NO_RETURN #define MUNIT_NO_RETURN
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER >= 1500) #if defined(_MSC_VER) && (_MSC_VER >= 1500)
# define MUNIT_PUSH_DISABLE_MSVC_C4127_ __pragma(warning(push)) __pragma(warning(disable:4127)) #define MUNIT_PUSH_DISABLE_MSVC_C4127_ \
# define MUNIT_POP_DISABLE_MSVC_C4127_ __pragma(warning(pop)) __pragma(warning(push)) __pragma(warning(disable : 4127))
#define MUNIT_POP_DISABLE_MSVC_C4127_ __pragma(warning(pop))
#else #else
# define MUNIT_PUSH_DISABLE_MSVC_C4127_ #define MUNIT_PUSH_DISABLE_MSVC_C4127_
# define MUNIT_POP_DISABLE_MSVC_C4127_ #define MUNIT_POP_DISABLE_MSVC_C4127_
#endif #endif
typedef enum { typedef enum {
MUNIT_LOG_DEBUG, MUNIT_LOG_DEBUG,
MUNIT_LOG_INFO, MUNIT_LOG_INFO,
MUNIT_LOG_WARNING, MUNIT_LOG_WARNING,
MUNIT_LOG_ERROR MUNIT_LOG_ERROR
} MunitLogLevel; } MunitLogLevel;
#if defined(__GNUC__) && !defined(__MINGW32__) #if defined(__GNUC__) && !defined(__MINGW32__)
# define MUNIT_PRINTF(string_index, first_to_check) __attribute__((format (printf, string_index, first_to_check))) #define MUNIT_PRINTF(string_index, first_to_check) \
__attribute__((format(printf, string_index, first_to_check)))
#else #else
# define MUNIT_PRINTF(string_index, first_to_check) #define MUNIT_PRINTF(string_index, first_to_check)
#endif #endif
MUNIT_PRINTF(4, 5) MUNIT_PRINTF(4, 5)
void munit_logf_ex(MunitLogLevel level, const char* filename, int line, const char* format, ...); void munit_logf_ex(MunitLogLevel level, const char *filename, int line,
const char *format, ...);
#define munit_logf(level, format, ...) \ #define munit_logf(level, format, ...) \
munit_logf_ex(level, __FILE__, __LINE__, format, __VA_ARGS__) munit_logf_ex(level, __FILE__, __LINE__, format, __VA_ARGS__)
#define munit_log(level, msg) \ #define munit_log(level, msg) munit_logf(level, "%s", msg)
munit_logf(level, "%s", msg)
MUNIT_NO_RETURN MUNIT_NO_RETURN
MUNIT_PRINTF(3, 4) MUNIT_PRINTF(3, 4)
void munit_errorf_ex(const char* filename, int line, const char* format, ...); void munit_errorf_ex(const char *filename, int line, const char *format, ...);
#define munit_errorf(format, ...) \ #define munit_errorf(format, ...) \
munit_errorf_ex(__FILE__, __LINE__, format, __VA_ARGS__) munit_errorf_ex(__FILE__, __LINE__, format, __VA_ARGS__)
#define munit_error(msg) \ #define munit_error(msg) munit_errorf("%s", msg)
munit_errorf("%s", msg)
#define munit_assert(expr) \ #define munit_assert(expr) \
do { \ do { \
if (!MUNIT_LIKELY(expr)) { \ if (!MUNIT_LIKELY(expr)) { \
munit_error("assertion failed: " #expr); \ munit_error("assertion failed: " #expr); \
} \ } \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
} while (0) \ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_true(expr) \ #define munit_assert_true(expr) \
do { \ do { \
if (!MUNIT_LIKELY(expr)) { \ if (!MUNIT_LIKELY(expr)) { \
munit_error("assertion failed: " #expr " is not true"); \ munit_error("assertion failed: " #expr " is not true"); \
} \ } \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
} while (0) \ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_false(expr) \ #define munit_assert_false(expr) \
do { \ do { \
if (!MUNIT_LIKELY(!(expr))) { \ if (!MUNIT_LIKELY(!(expr))) { \
munit_error("assertion failed: " #expr " is not false"); \ munit_error("assertion failed: " #expr " is not false"); \
} \ } \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
} while (0) \ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_type_full(prefix, suffix, T, fmt, a, op, b) \ #define munit_assert_type_full(prefix, suffix, T, fmt, a, op, b) \
do { \ do { \
T munit_tmp_a_ = (a); \ T munit_tmp_a_ = (a); \
T munit_tmp_b_ = (b); \ T munit_tmp_b_ = (b); \
if (!(munit_tmp_a_ op munit_tmp_b_)) { \ if (!(munit_tmp_a_ op munit_tmp_b_)) { \
munit_errorf("assertion failed: %s %s %s (" prefix "%" fmt suffix " %s " prefix "%" fmt suffix ")", \ munit_errorf("assertion failed: %s %s %s (" prefix "%" fmt suffix \
#a, #op, #b, munit_tmp_a_, #op, munit_tmp_b_); \ " %s " prefix "%" fmt suffix ")", \
} \ #a, #op, #b, munit_tmp_a_, #op, munit_tmp_b_); \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ } \
} while (0) \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
MUNIT_POP_DISABLE_MSVC_C4127_ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_type(T, fmt, a, op, b) \ #define munit_assert_type(T, fmt, a, op, b) \
munit_assert_type_full("", "", T, fmt, a, op, b) munit_assert_type_full("", "", T, fmt, a, op, b)
#define munit_assert_char(a, op, b) \ #define munit_assert_char(a, op, b) \
munit_assert_type_full("'\\x", "'", char, "02" MUNIT_CHAR_MODIFIER "x", a, op, b) munit_assert_type_full("'\\x", "'", char, "02" MUNIT_CHAR_MODIFIER "x", a, \
#define munit_assert_uchar(a, op, b) \ op, b)
munit_assert_type_full("'\\x", "'", unsigned char, "02" MUNIT_CHAR_MODIFIER "x", a, op, b) #define munit_assert_uchar(a, op, b) \
munit_assert_type_full("'\\x", "'", unsigned char, \
"02" MUNIT_CHAR_MODIFIER "x", a, op, b)
#define munit_assert_short(a, op, b) \ #define munit_assert_short(a, op, b) \
munit_assert_type(short, MUNIT_SHORT_MODIFIER "d", a, op, b) munit_assert_type(short, MUNIT_SHORT_MODIFIER "d", a, op, b)
#define munit_assert_ushort(a, op, b) \ #define munit_assert_ushort(a, op, b) \
munit_assert_type(unsigned short, MUNIT_SHORT_MODIFIER "u", a, op, b) munit_assert_type(unsigned short, MUNIT_SHORT_MODIFIER "u", a, op, b)
#define munit_assert_int(a, op, b) \ #define munit_assert_int(a, op, b) munit_assert_type(int, "d", a, op, b)
munit_assert_type(int, "d", a, op, b)
#define munit_assert_uint(a, op, b) \ #define munit_assert_uint(a, op, b) \
munit_assert_type(unsigned int, "u", a, op, b) munit_assert_type(unsigned int, "u", a, op, b)
#define munit_assert_long(a, op, b) \ #define munit_assert_long(a, op, b) munit_assert_type(long int, "ld", a, op, b)
munit_assert_type(long int, "ld", a, op, b)
#define munit_assert_ulong(a, op, b) \ #define munit_assert_ulong(a, op, b) \
munit_assert_type(unsigned long int, "lu", a, op, b) munit_assert_type(unsigned long int, "lu", a, op, b)
#define munit_assert_llong(a, op, b) \ #define munit_assert_llong(a, op, b) \
munit_assert_type(long long int, "lld", a, op, b) munit_assert_type(long long int, "lld", a, op, b)
#define munit_assert_ullong(a, op, b) \ #define munit_assert_ullong(a, op, b) \
munit_assert_type(unsigned long long int, "llu", a, op, b) munit_assert_type(unsigned long long int, "llu", a, op, b)
#define munit_assert_size(a, op, b) \ #define munit_assert_size(a, op, b) \
munit_assert_type(size_t, MUNIT_SIZE_MODIFIER "u", a, op, b) munit_assert_type(size_t, MUNIT_SIZE_MODIFIER "u", a, op, b)
#define munit_assert_float(a, op, b) \ #define munit_assert_float(a, op, b) munit_assert_type(float, "f", a, op, b)
munit_assert_type(float, "f", a, op, b) #define munit_assert_double(a, op, b) munit_assert_type(double, "g", a, op, b)
#define munit_assert_double(a, op, b) \
munit_assert_type(double, "g", a, op, b)
#define munit_assert_ptr(a, op, b) \ #define munit_assert_ptr(a, op, b) \
munit_assert_type(const void*, "p", a, op, b) munit_assert_type(const void *, "p", a, op, b)
#define munit_assert_int8(a, op, b) \ #define munit_assert_int8(a, op, b) \
munit_assert_type(munit_int8_t, PRIi8, a, op, b) munit_assert_type(munit_int8_t, PRIi8, a, op, b)
#define munit_assert_uint8(a, op, b) \ #define munit_assert_uint8(a, op, b) \
munit_assert_type(munit_uint8_t, PRIu8, a, op, b) munit_assert_type(munit_uint8_t, PRIu8, a, op, b)
#define munit_assert_int16(a, op, b) \ #define munit_assert_int16(a, op, b) \
munit_assert_type(munit_int16_t, PRIi16, a, op, b) munit_assert_type(munit_int16_t, PRIi16, a, op, b)
#define munit_assert_uint16(a, op, b) \ #define munit_assert_uint16(a, op, b) \
munit_assert_type(munit_uint16_t, PRIu16, a, op, b) munit_assert_type(munit_uint16_t, PRIu16, a, op, b)
#define munit_assert_int32(a, op, b) \ #define munit_assert_int32(a, op, b) \
munit_assert_type(munit_int32_t, PRIi32, a, op, b) munit_assert_type(munit_int32_t, PRIi32, a, op, b)
#define munit_assert_uint32(a, op, b) \ #define munit_assert_uint32(a, op, b) \
munit_assert_type(munit_uint32_t, PRIu32, a, op, b) munit_assert_type(munit_uint32_t, PRIu32, a, op, b)
#define munit_assert_int64(a, op, b) \ #define munit_assert_int64(a, op, b) \
munit_assert_type(munit_int64_t, PRIi64, a, op, b) munit_assert_type(munit_int64_t, PRIi64, a, op, b)
#define munit_assert_uint64(a, op, b) \ #define munit_assert_uint64(a, op, b) \
munit_assert_type(munit_uint64_t, PRIu64, a, op, b) munit_assert_type(munit_uint64_t, PRIu64, a, op, b)
#define munit_assert_double_equal(a, b, precision) \ #define munit_assert_double_equal(a, b, precision) \
do { \ do { \
const double munit_tmp_a_ = (a); \ const double munit_tmp_a_ = (a); \
const double munit_tmp_b_ = (b); \ const double munit_tmp_b_ = (b); \
const double munit_tmp_diff_ = ((munit_tmp_a_ - munit_tmp_b_) < 0) ? \ const double munit_tmp_diff_ = ((munit_tmp_a_ - munit_tmp_b_) < 0) ? \
-(munit_tmp_a_ - munit_tmp_b_) : \ -(munit_tmp_a_ - munit_tmp_b_) : \
(munit_tmp_a_ - munit_tmp_b_); \ (munit_tmp_a_ - munit_tmp_b_); \
if (MUNIT_UNLIKELY(munit_tmp_diff_ > 1e-##precision)) { \ if (MUNIT_UNLIKELY(munit_tmp_diff_ > 1e-##precision)) { \
munit_errorf("assertion failed: %s == %s (%0." #precision "g == %0." #precision "g)", \ munit_errorf("assertion failed: %s == %s (%0." #precision \
#a, #b, munit_tmp_a_, munit_tmp_b_); \ "g == %0." #precision "g)", \
} \ #a, #b, munit_tmp_a_, munit_tmp_b_); \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ } \
} while (0) \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
MUNIT_POP_DISABLE_MSVC_C4127_ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#include <string.h> #include <string.h>
#define munit_assert_string_equal(a, b) \ #define munit_assert_string_equal(a, b) \
do { \ do { \
const char* munit_tmp_a_ = a; \ const char *munit_tmp_a_ = a; \
const char* munit_tmp_b_ = b; \ const char *munit_tmp_b_ = b; \
if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) != 0)) { \ if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) != 0)) { \
munit_errorf("assertion failed: string %s == %s (\"%s\" == \"%s\")", \ munit_errorf( \
#a, #b, munit_tmp_a_, munit_tmp_b_); \ "assertion failed: string %s == %s (\"%s\" == \"%s\")", #a, \
} \ #b, munit_tmp_a_, munit_tmp_b_); \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ } \
} while (0) \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
MUNIT_POP_DISABLE_MSVC_C4127_ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_string_not_equal(a, b) \ #define munit_assert_string_not_equal(a, b) \
do { \ do { \
const char* munit_tmp_a_ = a; \ const char *munit_tmp_a_ = a; \
const char* munit_tmp_b_ = b; \ const char *munit_tmp_b_ = b; \
if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) == 0)) { \ if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) == 0)) { \
munit_errorf("assertion failed: string %s != %s (\"%s\" == \"%s\")", \ munit_errorf( \
#a, #b, munit_tmp_a_, munit_tmp_b_); \ "assertion failed: string %s != %s (\"%s\" == \"%s\")", #a, \
} \ #b, munit_tmp_a_, munit_tmp_b_); \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ } \
} while (0) \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
MUNIT_POP_DISABLE_MSVC_C4127_ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_memory_equal(size, a, b) \ #define munit_assert_memory_equal(size, a, b) \
do { \ do { \
const unsigned char* munit_tmp_a_ = (const unsigned char*) (a); \ const unsigned char *munit_tmp_a_ = (const unsigned char *)(a); \
const unsigned char* munit_tmp_b_ = (const unsigned char*) (b); \ const unsigned char *munit_tmp_b_ = (const unsigned char *)(b); \
const size_t munit_tmp_size_ = (size); \ const size_t munit_tmp_size_ = (size); \
if (MUNIT_UNLIKELY(memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) != 0) { \ if (MUNIT_UNLIKELY( \
size_t munit_tmp_pos_; \ memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) != 0) { \
for (munit_tmp_pos_ = 0 ; munit_tmp_pos_ < munit_tmp_size_ ; munit_tmp_pos_++) { \ size_t munit_tmp_pos_; \
if (munit_tmp_a_[munit_tmp_pos_] != munit_tmp_b_[munit_tmp_pos_]) { \ for (munit_tmp_pos_ = 0; munit_tmp_pos_ < munit_tmp_size_; \
munit_errorf("assertion failed: memory %s == %s, at offset %" MUNIT_SIZE_MODIFIER "u", \ munit_tmp_pos_++) { \
#a, #b, munit_tmp_pos_); \ if (munit_tmp_a_[munit_tmp_pos_] != \
break; \ munit_tmp_b_[munit_tmp_pos_]) { \
} \ munit_errorf( \
} \ "assertion failed: memory %s == %s, at offset %" MUNIT_SIZE_MODIFIER \
} \ "u", \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ #a, #b, munit_tmp_pos_); \
} while (0) \ break; \
MUNIT_POP_DISABLE_MSVC_C4127_ } \
} \
} \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \
} while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_memory_not_equal(size, a, b) \ #define munit_assert_memory_not_equal(size, a, b) \
do { \ do { \
const unsigned char* munit_tmp_a_ = (const unsigned char*) (a); \ const unsigned char *munit_tmp_a_ = (const unsigned char *)(a); \
const unsigned char* munit_tmp_b_ = (const unsigned char*) (b); \ const unsigned char *munit_tmp_b_ = (const unsigned char *)(b); \
const size_t munit_tmp_size_ = (size); \ const size_t munit_tmp_size_ = (size); \
if (MUNIT_UNLIKELY(memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) == 0) { \ if (MUNIT_UNLIKELY( \
munit_errorf("assertion failed: memory %s != %s (%zu bytes)", \ memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) == 0) { \
#a, #b, munit_tmp_size_); \ munit_errorf("assertion failed: memory %s != %s (%zu bytes)", #a, \
} \ #b, munit_tmp_size_); \
MUNIT_PUSH_DISABLE_MSVC_C4127_ \ } \
} while (0) \ MUNIT_PUSH_DISABLE_MSVC_C4127_ \
MUNIT_POP_DISABLE_MSVC_C4127_ } while (0) MUNIT_POP_DISABLE_MSVC_C4127_
#define munit_assert_ptr_equal(a, b) \ #define munit_assert_ptr_equal(a, b) munit_assert_ptr(a, ==, b)
munit_assert_ptr(a, ==, b) #define munit_assert_ptr_not_equal(a, b) munit_assert_ptr(a, !=, b)
#define munit_assert_ptr_not_equal(a, b) \ #define munit_assert_null(ptr) munit_assert_ptr(ptr, ==, NULL)
munit_assert_ptr(a, !=, b) #define munit_assert_not_null(ptr) munit_assert_ptr(ptr, !=, NULL)
#define munit_assert_null(ptr) \ #define munit_assert_ptr_null(ptr) munit_assert_ptr(ptr, ==, NULL)
munit_assert_ptr(ptr, ==, NULL) #define munit_assert_ptr_not_null(ptr) munit_assert_ptr(ptr, !=, NULL)
#define munit_assert_not_null(ptr) \
munit_assert_ptr(ptr, !=, NULL)
#define munit_assert_ptr_null(ptr) \
munit_assert_ptr(ptr, ==, NULL)
#define munit_assert_ptr_not_null(ptr) \
munit_assert_ptr(ptr, !=, NULL)
/*** Memory allocation ***/ /*** Memory allocation ***/
void* munit_malloc_ex(const char* filename, int line, size_t size); void *munit_malloc_ex(const char *filename, int line, size_t size);
#define munit_malloc(size) \ #define munit_malloc(size) munit_malloc_ex(__FILE__, __LINE__, (size))
munit_malloc_ex(__FILE__, __LINE__, (size))
#define munit_new(type) \ #define munit_new(type) ((type *)munit_malloc(sizeof(type)))
((type*) munit_malloc(sizeof(type)))
#define munit_calloc(nmemb, size) \ #define munit_calloc(nmemb, size) munit_malloc((nmemb) * (size))
munit_malloc((nmemb) * (size))
#define munit_newa(type, nmemb) \ #define munit_newa(type, nmemb) ((type *)munit_calloc((nmemb), sizeof(type)))
((type*) munit_calloc((nmemb), sizeof(type)))
/*** Random number generation ***/ /*** Random number generation ***/
@ -398,69 +389,71 @@ void munit_rand_seed(munit_uint32_t seed);
munit_uint32_t munit_rand_uint32(void); munit_uint32_t munit_rand_uint32(void);
int munit_rand_int_range(int min, int max); int munit_rand_int_range(int min, int max);
double munit_rand_double(void); double munit_rand_double(void);
void munit_rand_memory(size_t size, munit_uint8_t buffer[MUNIT_ARRAY_PARAM(size)]); void munit_rand_memory(size_t size,
munit_uint8_t buffer[MUNIT_ARRAY_PARAM(size)]);
/*** Tests and Suites ***/ /*** Tests and Suites ***/
typedef enum { typedef enum {
/* Test successful */ /* Test successful */
MUNIT_OK, MUNIT_OK,
/* Test failed */ /* Test failed */
MUNIT_FAIL, MUNIT_FAIL,
/* Test was skipped */ /* Test was skipped */
MUNIT_SKIP, MUNIT_SKIP,
/* Test failed due to circumstances not intended to be tested /* Test failed due to circumstances not intended to be tested
* (things like network errors, invalid parameter value, failure to * (things like network errors, invalid parameter value, failure to
* allocate memory in the test harness, etc.). */ * allocate memory in the test harness, etc.). */
MUNIT_ERROR MUNIT_ERROR
} MunitResult; } MunitResult;
typedef struct { typedef struct {
char* name; char *name;
char** values; char **values;
} MunitParameterEnum; } MunitParameterEnum;
typedef struct { typedef struct {
char* name; char *name;
char* value; char *value;
} MunitParameter; } MunitParameter;
const char* munit_parameters_get(const MunitParameter params[], const char* key); const char *munit_parameters_get(const MunitParameter params[],
const char *key);
typedef enum { typedef enum {
MUNIT_TEST_OPTION_NONE = 0, MUNIT_TEST_OPTION_NONE = 0,
MUNIT_TEST_OPTION_SINGLE_ITERATION = 1 << 0, MUNIT_TEST_OPTION_SINGLE_ITERATION = 1 << 0,
MUNIT_TEST_OPTION_TODO = 1 << 1 MUNIT_TEST_OPTION_TODO = 1 << 1
} MunitTestOptions; } MunitTestOptions;
typedef MunitResult (* MunitTestFunc)(const MunitParameter params[], void* user_data_or_fixture); typedef MunitResult (
typedef void* (* MunitTestSetup)(const MunitParameter params[], void* user_data); *MunitTestFunc)(const MunitParameter params[], void *user_data_or_fixture);
typedef void (* MunitTestTearDown)(void* fixture); typedef void *(*MunitTestSetup)(const MunitParameter params[], void *user_data);
typedef void (*MunitTestTearDown)(void *fixture);
typedef struct { typedef struct {
char* name; char *name;
MunitTestFunc test; MunitTestFunc test;
MunitTestSetup setup; MunitTestSetup setup;
MunitTestTearDown tear_down; MunitTestTearDown tear_down;
MunitTestOptions options; MunitTestOptions options;
MunitParameterEnum* parameters; MunitParameterEnum *parameters;
} MunitTest; } MunitTest;
typedef enum { typedef enum { MUNIT_SUITE_OPTION_NONE = 0 } MunitSuiteOptions;
MUNIT_SUITE_OPTION_NONE = 0
} MunitSuiteOptions;
typedef struct MunitSuite_ MunitSuite; typedef struct MunitSuite_ MunitSuite;
struct MunitSuite_ { struct MunitSuite_ {
char* prefix; char *prefix;
MunitTest* tests; MunitTest *tests;
MunitSuite* suites; MunitSuite *suites;
unsigned int iterations; unsigned int iterations;
MunitSuiteOptions options; MunitSuiteOptions options;
}; };
int munit_suite_main(const MunitSuite* suite, void* user_data, int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)]); int munit_suite_main(const MunitSuite *suite, void *user_data, int argc,
char *const argv[MUNIT_ARRAY_PARAM(argc + 1)]);
/* Note: I'm not very happy with this API; it's likely to change if I /* Note: I'm not very happy with this API; it's likely to change if I
* figure out something better. Suggestions welcome. */ * figure out something better. Suggestions welcome. */
@ -468,15 +461,15 @@ int munit_suite_main(const MunitSuite* suite, void* user_data, int argc, char* c
typedef struct MunitArgument_ MunitArgument; typedef struct MunitArgument_ MunitArgument;
struct MunitArgument_ { struct MunitArgument_ {
char* name; char *name;
munit_bool (* parse_argument)(const MunitSuite* suite, void* user_data, int* arg, int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)]); munit_bool (*parse_argument)(const MunitSuite *suite, void *user_data,
void (* write_help)(const MunitArgument* argument, void* user_data); int *arg, int argc, char *const argv[MUNIT_ARRAY_PARAM(argc + 1)]);
void (*write_help)(const MunitArgument *argument, void *user_data);
}; };
int munit_suite_main_custom(const MunitSuite* suite, int munit_suite_main_custom(const MunitSuite *suite, void *user_data, int argc,
void* user_data, char *const argv[MUNIT_ARRAY_PARAM(argc + 1)],
int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)], const MunitArgument arguments[]);
const MunitArgument arguments[]);
#if defined(MUNIT_ENABLE_ASSERT_ALIASES) #if defined(MUNIT_ENABLE_ASSERT_ALIASES)
@ -506,11 +499,13 @@ int munit_suite_main_custom(const MunitSuite* suite,
#define assert_int64(a, op, b) munit_assert_int64(a, op, b) #define assert_int64(a, op, b) munit_assert_int64(a, op, b)
#define assert_uint64(a, op, b) munit_assert_uint64(a, op, b) #define assert_uint64(a, op, b) munit_assert_uint64(a, op, b)
#define assert_double_equal(a, b, precision) munit_assert_double_equal(a, b, precision) #define assert_double_equal(a, b, precision) \
munit_assert_double_equal(a, b, precision)
#define assert_string_equal(a, b) munit_assert_string_equal(a, b) #define assert_string_equal(a, b) munit_assert_string_equal(a, b)
#define assert_string_not_equal(a, b) munit_assert_string_not_equal(a, b) #define assert_string_not_equal(a, b) munit_assert_string_not_equal(a, b)
#define assert_memory_equal(size, a, b) munit_assert_memory_equal(size, a, b) #define assert_memory_equal(size, a, b) munit_assert_memory_equal(size, a, b)
#define assert_memory_not_equal(size, a, b) munit_assert_memory_not_equal(size, a, b) #define assert_memory_not_equal(size, a, b) \
munit_assert_memory_not_equal(size, a, b)
#define assert_ptr_equal(a, b) munit_assert_ptr_equal(a, b) #define assert_ptr_equal(a, b) munit_assert_ptr_equal(a, b)
#define assert_ptr_not_equal(a, b) munit_assert_ptr_not_equal(a, b) #define assert_ptr_not_equal(a, b) munit_assert_ptr_not_equal(a, b)
#define assert_ptr_null(ptr) munit_assert_null_equal(ptr) #define assert_ptr_null(ptr) munit_assert_null_equal(ptr)
@ -528,8 +523,8 @@ int munit_suite_main_custom(const MunitSuite* suite,
#endif /* !defined(MUNIT_H) */ #endif /* !defined(MUNIT_H) */
#if defined(MUNIT_ENABLE_ASSERT_ALIASES) #if defined(MUNIT_ENABLE_ASSERT_ALIASES)
# if defined(assert) #if defined(assert)
# undef assert #undef assert
# endif #endif
# define assert(expr) munit_assert(expr) #define assert(expr) munit_assert(expr)
#endif #endif

View file

@ -1,5 +0,0 @@
static MunitTest scale_tests[] = {
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
};

View file

@ -7,8 +7,10 @@
* details. * details.
*/ */
#define MUNIT_NO_FORK (1)
#define MUNIT_ENABLE_ASSERT_ALIASES (1) #define MUNIT_ENABLE_ASSERT_ALIASES (1)
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define __SL_DEBUG 0 #define __SL_DEBUG 0
@ -119,7 +121,265 @@ uint32_key_cmp(sl_node *a, sl_node *b, void *aux)
return 0; return 0;
} }
#include "api.c" static void *
test_api_setup(const MunitParameter params[], void *user_data)
{
struct test_info *info = (struct test_info *)user_data;
(void)info;
(void)params;
ex_sl_t *slist = calloc(sizeof(ex_sl_t), 1);
if (slist == NULL)
return NULL;
sl_init(slist, uint32_key_cmp);
return (void *)(uintptr_t)slist;
}
static void
test_api_tear_down(void *fixture)
{
ex_sl_t *slist = (ex_sl_t *)fixture;
assert_ptr_not_null(slist);
sl_node *cursor = sl_begin(slist);
while (cursor) {
assert_ptr_not_null(cursor);
ex_node_t *entry = sl_get_entry(cursor, ex_node_t, snode);
assert_ptr_not_null(entry);
assert_uint32(entry->key, ==, entry->value);
cursor = sl_next(slist, cursor);
sl_erase_node(slist, &entry->snode);
sl_release_node(&entry->snode);
sl_wait_for_free(&entry->snode);
sl_free_node(&entry->snode);
free(entry);
}
sl_free(slist);
free(fixture);
}
static size_t
__populate_slist(ex_sl_t *slist){
size_t inserted = 0;
uint32_t n, key;
ex_node_t *node;
n = munit_rand_int_range(1024, 4196);
while (n--) {
key = munit_rand_int_range(0, (((uint32_t)0) - 1) / 10);
node = (ex_node_t *)calloc(sizeof(ex_node_t), 1);
if (node == NULL)
return MUNIT_ERROR;
sl_init_node(&node->snode);
node->key = key;
node->value = key;
if (sl_insert_nodup(slist, &node->snode) == -1)
continue; /* a random duplicate appeared */
else
inserted++;
}
return inserted;
}
static void *
test_api_insert_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_insert_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_insert(const MunitParameter params[], void *data)
{
int ret;
size_t inserted = 0;
uint32_t n, key;
sl_raw *slist = (sl_raw *)data;
ex_node_t *node;
(void)params;
assert_ptr_not_null(slist);
n = munit_rand_int_range(4096, 8192);
while (n--) {
key = munit_rand_int_range(0, ((uint32_t)0-1) / 10);
node = (ex_node_t *)calloc(sizeof(ex_node_t), 1);
if (node == NULL)
return MUNIT_ERROR;
sl_init_node(&node->snode);
node->key = key;
node->value = key;
if ((ret = sl_insert_nodup(slist, &node->snode)) == -1)
continue; /* a random duplicate appeared */
else {
assert_int(ret, ==, 0);
inserted++;
}
}
assert_size(inserted, ==, sl_get_size(slist));
return MUNIT_OK;
}
static void *
test_api_remove_setup(const MunitParameter params[], void *user_data)
{
sl_raw *slist = (sl_raw *)test_api_setup(params, user_data);
__populate_slist(slist);
return (void *)slist;
}
static void
test_api_remove_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_remove(const MunitParameter params[], void *data)
{
uint32_t key;
sl_raw *slist = (sl_raw *)data;
ex_node_t *node;
(void)params;
assert_ptr_not_null(slist);
key = munit_rand_int_range((((uint32_t)0-1) / 10) + 1, ((uint32_t)0-1));
node = (ex_node_t *)calloc(sizeof(ex_node_t), 1);
if (node == NULL)
return MUNIT_ERROR;
sl_init_node(&node->snode);
node->key = key;
node->value = key;
if (sl_insert_nodup(slist, &node->snode) == -1)
return MUNIT_ERROR;
else {
ex_node_t query;
query.key = key;
sl_node *cursor = sl_find(slist, &query.snode);
assert_ptr_not_null(cursor);
ex_node_t *entry = sl_get_entry(cursor, ex_node_t, snode);
sl_erase_node(slist, &entry->snode);
sl_release_node(&entry->snode);
sl_wait_for_free(&entry->snode);
sl_free_node(&entry->snode);
free(entry);
}
return MUNIT_OK;
}
static void *
test_api_find_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_find_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_find(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static void *
test_api_update_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_update_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_update(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static void *
test_api_delete_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_delete_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_delete(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static void *
test_api_duplicates_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_duplicates_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_duplicates(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static void *
test_api_size_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_size_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_size(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static void *
test_api_iterators_setup(const MunitParameter params[], void *user_data)
{
return test_api_setup(params, user_data);
}
static void
test_api_iterators_tear_down(void *fixture)
{
test_api_tear_down(fixture);
}
static MunitResult
test_api_iterators(const MunitParameter params[], void *data)
{
sl_raw *slist = (sl_raw *)data;
(void)params;
(void)slist;
return MUNIT_OK;
}
static MunitTest api_test_suite[] = { static MunitTest api_test_suite[] = {
{ (char *)"/api/insert", test_api_insert, test_api_insert_setup, { (char *)"/api/insert", test_api_insert, test_api_insert_setup,
test_api_insert_tear_down, MUNIT_TEST_OPTION_NONE, NULL }, test_api_insert_tear_down, MUNIT_TEST_OPTION_NONE, NULL },
@ -140,17 +400,19 @@ static MunitTest api_test_suite[] = {
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
}; };
#include "mt.c" static MunitTest mt_tests[] = { { NULL, NULL, NULL, NULL,
#include "scale.c" MUNIT_TEST_OPTION_NONE, NULL } };
static MunitSuite other_test_suite[] = {
{ "/mt", mt_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ "/scale", scale_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE}
};
static const MunitSuite main_test_suite = { static MunitTest scale_tests[] = { { NULL, NULL, NULL, NULL,
(char *)"/api", api_test_suite,other_test_suite, 1, MUNIT_SUITE_OPTION_NONE MUNIT_TEST_OPTION_NONE, NULL } };
};
static MunitSuite other_test_suite[] = { { "/mt", mt_tests, NULL, 1,
MUNIT_SUITE_OPTION_NONE },
{ "/scale", scale_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE } };
static const MunitSuite main_test_suite = { (char *)"/api", api_test_suite,
other_test_suite, 1, MUNIT_SUITE_OPTION_NONE };
int int
main(int argc, char *argv[MUNIT_ARRAY_PARAM(argc + 1)]) main(int argc, char *argv[MUNIT_ARRAY_PARAM(argc + 1)])