diff --git a/Makefile b/Makefile index 2adbaa2..8099e22 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ 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 STATIC_LIB = libskiplist.a @@ -31,6 +32,7 @@ tests/%.o: tests/%.c test: $(TESTS) ./tests/test +# env LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/test tests/test: tests/test.o tests/munit.o $(STATIC_LIB) $(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread @@ -47,4 +49,4 @@ clean: rm -f $(EXAMPLES) format: - clang-format -i include/*.h src/*.c tests/*.c + clang-format -i include/*.h src/*.c tests/*.c tests/*.h diff --git a/tests/api.c b/tests/api.c index 80e9998..9a2e76c 100644 --- a/tests/api.c +++ b/tests/api.c @@ -35,12 +35,14 @@ test_api_tear_down(void *fixture) } static void * -test_api_insert_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_insert_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_insert(const MunitParameter params[], void *data) @@ -61,12 +63,14 @@ test_api_insert(const MunitParameter params[], void *data) } static void * -test_api_remove_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +test_api_remove_setup(const MunitParameter params[], void *user_data) +{ + return test_api_setup(params, user_data); } static void -test_api_remove_tear_down(void *fixture) { - test_api_tear_down(fixture); +test_api_remove_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_remove(const MunitParameter params[], void *data) @@ -78,12 +82,14 @@ test_api_remove(const MunitParameter params[], void *data) } static void * -test_api_find_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_find_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_find(const MunitParameter params[], void *data) @@ -95,12 +101,14 @@ test_api_find(const MunitParameter params[], void *data) } static void * -test_api_update_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_update_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_update(const MunitParameter params[], void *data) @@ -112,12 +120,14 @@ test_api_update(const MunitParameter params[], void *data) } static void * -test_api_delete_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_delete_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_delete(const MunitParameter params[], void *data) @@ -129,12 +139,14 @@ test_api_delete(const MunitParameter params[], void *data) } static void * -test_api_duplicates_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_duplicates_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_duplicates(const MunitParameter params[], void *data) @@ -146,12 +158,14 @@ test_api_duplicates(const MunitParameter params[], void *data) } static void * -test_api_size_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_size_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_size(const MunitParameter params[], void *data) @@ -163,12 +177,14 @@ test_api_size(const MunitParameter params[], void *data) } static void * -test_api_iterators_setup(const MunitParameter params[], void *user_data) { - return test_api_setup(params, user_data); +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); +test_api_iterators_tear_down(void *fixture) +{ + test_api_tear_down(fixture); } static MunitResult test_api_iterators(const MunitParameter params[], void *data) diff --git a/tests/mt.c b/tests/mt.c deleted file mode 100644 index 273bae4..0000000 --- a/tests/mt.c +++ /dev/null @@ -1,5 +0,0 @@ - -static MunitTest mt_tests[] = { - { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } -}; - diff --git a/tests/munit.h b/tests/munit.h index 8460a45..87c7615 100644 --- a/tests/munit.h +++ b/tests/munit.h @@ -29,92 +29,92 @@ #include #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) #if defined(_MSC_VER) && (_MSC_VER < 1600) -# define munit_int8_t __int8 -# define munit_uint8_t unsigned __int8 -# define munit_int16_t __int16 -# define munit_uint16_t unsigned __int16 -# define munit_int32_t __int32 -# define munit_uint32_t unsigned __int32 -# define munit_int64_t __int64 -# define munit_uint64_t unsigned __int64 +#define munit_int8_t __int8 +#define munit_uint8_t unsigned __int8 +#define munit_int16_t __int16 +#define munit_uint16_t unsigned __int16 +#define munit_int32_t __int32 +#define munit_uint32_t unsigned __int32 +#define munit_int64_t __int64 +#define munit_uint64_t unsigned __int64 #else -# include -# define munit_int8_t int8_t -# define munit_uint8_t uint8_t -# define munit_int16_t int16_t -# define munit_uint16_t uint16_t -# define munit_int32_t int32_t -# define munit_uint32_t uint32_t -# define munit_int64_t int64_t -# define munit_uint64_t uint64_t +#include +#define munit_int8_t int8_t +#define munit_uint8_t uint8_t +#define munit_int16_t int16_t +#define munit_uint16_t uint16_t +#define munit_int32_t int32_t +#define munit_uint32_t uint32_t +#define munit_int64_t int64_t +#define munit_uint64_t uint64_t #endif #if defined(_MSC_VER) && (_MSC_VER < 1800) -# if !defined(PRIi8) -# define PRIi8 "i" -# endif -# if !defined(PRIi16) -# define PRIi16 "i" -# endif -# if !defined(PRIi32) -# define PRIi32 "i" -# endif -# if !defined(PRIi64) -# define PRIi64 "I64i" -# endif -# if !defined(PRId8) -# define PRId8 "d" -# endif -# if !defined(PRId16) -# define PRId16 "d" -# endif -# if !defined(PRId32) -# define PRId32 "d" -# endif -# if !defined(PRId64) -# define PRId64 "I64d" -# endif -# if !defined(PRIx8) -# define PRIx8 "x" -# endif -# if !defined(PRIx16) -# define PRIx16 "x" -# endif -# if !defined(PRIx32) -# define PRIx32 "x" -# endif -# if !defined(PRIx64) -# define PRIx64 "I64x" -# endif -# if !defined(PRIu8) -# define PRIu8 "u" -# endif -# if !defined(PRIu16) -# define PRIu16 "u" -# endif -# if !defined(PRIu32) -# define PRIu32 "u" -# endif -# if !defined(PRIu64) -# define PRIu64 "I64u" -# endif +#if !defined(PRIi8) +#define PRIi8 "i" +#endif +#if !defined(PRIi16) +#define PRIi16 "i" +#endif +#if !defined(PRIi32) +#define PRIi32 "i" +#endif +#if !defined(PRIi64) +#define PRIi64 "I64i" +#endif +#if !defined(PRId8) +#define PRId8 "d" +#endif +#if !defined(PRId16) +#define PRId16 "d" +#endif +#if !defined(PRId32) +#define PRId32 "d" +#endif +#if !defined(PRId64) +#define PRId64 "I64d" +#endif +#if !defined(PRIx8) +#define PRIx8 "x" +#endif +#if !defined(PRIx16) +#define PRIx16 "x" +#endif +#if !defined(PRIx32) +#define PRIx32 "x" +#endif +#if !defined(PRIx64) +#define PRIx64 "I64x" +#endif +#if !defined(PRIu8) +#define PRIu8 "u" +#endif +#if !defined(PRIu16) +#define PRIu16 "u" +#endif +#if !defined(PRIu32) +#define PRIu32 "u" +#endif +#if !defined(PRIu64) +#define PRIu64 "I64u" +#endif #else -# include +#include #endif #if !defined(munit_bool) -# if defined(bool) -# define munit_bool bool -# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define munit_bool _Bool -# else -# define munit_bool int -# endif +#if defined(bool) +#define munit_bool bool +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#define munit_bool _Bool +#else +#define munit_bool int +#endif #endif #if defined(__cplusplus) @@ -122,275 +122,266 @@ extern "C" { #endif #if defined(__GNUC__) -# define MUNIT_LIKELY(expr) (__builtin_expect ((expr), 1)) -# define MUNIT_UNLIKELY(expr) (__builtin_expect ((expr), 0)) -# define MUNIT_UNUSED __attribute__((__unused__)) +#define MUNIT_LIKELY(expr) (__builtin_expect((expr), 1)) +#define MUNIT_UNLIKELY(expr) (__builtin_expect((expr), 0)) +#define MUNIT_UNUSED __attribute__((__unused__)) #else -# define MUNIT_LIKELY(expr) (expr) -# define MUNIT_UNLIKELY(expr) (expr) -# define MUNIT_UNUSED +#define MUNIT_LIKELY(expr) (expr) +#define MUNIT_UNLIKELY(expr) (expr) +#define MUNIT_UNUSED #endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__PGI) -# define MUNIT_ARRAY_PARAM(name) name +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__PGI) +#define MUNIT_ARRAY_PARAM(name) name #else -# define MUNIT_ARRAY_PARAM(name) +#define MUNIT_ARRAY_PARAM(name) #endif #if !defined(_WIN32) -# define MUNIT_SIZE_MODIFIER "z" -# define MUNIT_CHAR_MODIFIER "hh" -# define MUNIT_SHORT_MODIFIER "h" +#define MUNIT_SIZE_MODIFIER "z" +#define MUNIT_CHAR_MODIFIER "hh" +#define MUNIT_SHORT_MODIFIER "h" #else -# if defined(_M_X64) || defined(__amd64__) -# define MUNIT_SIZE_MODIFIER "I64" -# else -# define MUNIT_SIZE_MODIFIER "" -# endif -# define MUNIT_CHAR_MODIFIER "" -# define MUNIT_SHORT_MODIFIER "" +#if defined(_M_X64) || defined(__amd64__) +#define MUNIT_SIZE_MODIFIER "I64" +#else +#define MUNIT_SIZE_MODIFIER "" +#endif +#define MUNIT_CHAR_MODIFIER "" +#define MUNIT_SHORT_MODIFIER "" #endif #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -# define MUNIT_NO_RETURN _Noreturn +#define MUNIT_NO_RETURN _Noreturn #elif defined(__GNUC__) -# define MUNIT_NO_RETURN __attribute__((__noreturn__)) +#define MUNIT_NO_RETURN __attribute__((__noreturn__)) #elif defined(_MSC_VER) -# define MUNIT_NO_RETURN __declspec(noreturn) +#define MUNIT_NO_RETURN __declspec(noreturn) #else -# define MUNIT_NO_RETURN +#define MUNIT_NO_RETURN #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1500) -# define MUNIT_PUSH_DISABLE_MSVC_C4127_ __pragma(warning(push)) __pragma(warning(disable:4127)) -# define MUNIT_POP_DISABLE_MSVC_C4127_ __pragma(warning(pop)) +#if defined(_MSC_VER) && (_MSC_VER >= 1500) +#define MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + __pragma(warning(push)) __pragma(warning(disable : 4127)) +#define MUNIT_POP_DISABLE_MSVC_C4127_ __pragma(warning(pop)) #else -# define MUNIT_PUSH_DISABLE_MSVC_C4127_ -# define MUNIT_POP_DISABLE_MSVC_C4127_ +#define MUNIT_PUSH_DISABLE_MSVC_C4127_ +#define MUNIT_POP_DISABLE_MSVC_C4127_ #endif typedef enum { - MUNIT_LOG_DEBUG, - MUNIT_LOG_INFO, - MUNIT_LOG_WARNING, - MUNIT_LOG_ERROR + MUNIT_LOG_DEBUG, + MUNIT_LOG_INFO, + MUNIT_LOG_WARNING, + MUNIT_LOG_ERROR } MunitLogLevel; #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 -# define MUNIT_PRINTF(string_index, first_to_check) +#define MUNIT_PRINTF(string_index, first_to_check) #endif 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, ...) \ - munit_logf_ex(level, __FILE__, __LINE__, format, __VA_ARGS__) + munit_logf_ex(level, __FILE__, __LINE__, format, __VA_ARGS__) -#define munit_log(level, msg) \ - munit_logf(level, "%s", msg) +#define munit_log(level, msg) munit_logf(level, "%s", msg) MUNIT_NO_RETURN 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, ...) \ - munit_errorf_ex(__FILE__, __LINE__, format, __VA_ARGS__) + munit_errorf_ex(__FILE__, __LINE__, format, __VA_ARGS__) -#define munit_error(msg) \ - munit_errorf("%s", msg) +#define munit_error(msg) munit_errorf("%s", msg) -#define munit_assert(expr) \ - do { \ - if (!MUNIT_LIKELY(expr)) { \ - munit_error("assertion failed: " #expr); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert(expr) \ + do { \ + if (!MUNIT_LIKELY(expr)) { \ + munit_error("assertion failed: " #expr); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_true(expr) \ - do { \ - if (!MUNIT_LIKELY(expr)) { \ - munit_error("assertion failed: " #expr " is not true"); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_true(expr) \ + do { \ + if (!MUNIT_LIKELY(expr)) { \ + munit_error("assertion failed: " #expr " is not true"); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_false(expr) \ - do { \ - if (!MUNIT_LIKELY(!(expr))) { \ - munit_error("assertion failed: " #expr " is not false"); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_false(expr) \ + do { \ + if (!MUNIT_LIKELY(!(expr))) { \ + munit_error("assertion failed: " #expr " is not false"); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_type_full(prefix, suffix, T, fmt, a, op, b) \ - do { \ - T munit_tmp_a_ = (a); \ - T munit_tmp_b_ = (b); \ - if (!(munit_tmp_a_ op munit_tmp_b_)) { \ - munit_errorf("assertion failed: %s %s %s (" prefix "%" fmt suffix " %s " prefix "%" fmt suffix ")", \ - #a, #op, #b, munit_tmp_a_, #op, munit_tmp_b_); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_type_full(prefix, suffix, T, fmt, a, op, b) \ + do { \ + T munit_tmp_a_ = (a); \ + T munit_tmp_b_ = (b); \ + if (!(munit_tmp_a_ op munit_tmp_b_)) { \ + munit_errorf("assertion failed: %s %s %s (" prefix "%" fmt suffix \ + " %s " prefix "%" fmt suffix ")", \ + #a, #op, #b, munit_tmp_a_, #op, munit_tmp_b_); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ #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) \ - munit_assert_type_full("'\\x", "'", 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_char(a, op, b) \ + munit_assert_type_full("'\\x", "'", 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) \ - 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) \ - munit_assert_type(unsigned short, MUNIT_SHORT_MODIFIER "u", a, op, b) -#define munit_assert_int(a, op, b) \ - munit_assert_type(int, "d", a, op, b) + munit_assert_type(unsigned short, MUNIT_SHORT_MODIFIER "u", a, op, b) +#define munit_assert_int(a, op, b) munit_assert_type(int, "d", a, op, b) #define munit_assert_uint(a, op, b) \ - munit_assert_type(unsigned int, "u", a, op, b) -#define munit_assert_long(a, op, b) \ - munit_assert_type(long int, "ld", a, op, b) + munit_assert_type(unsigned int, "u", a, op, b) +#define munit_assert_long(a, op, b) munit_assert_type(long int, "ld", 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) \ - 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) \ - 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) \ - 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) \ - 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_float(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_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) \ - munit_assert_type(munit_int8_t, PRIi8, a, op, b) +#define munit_assert_int8(a, op, b) \ + munit_assert_type(munit_int8_t, PRIi8, 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) \ - 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) \ - 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) \ - 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) \ - 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) \ - 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) \ - 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) \ - do { \ - const double munit_tmp_a_ = (a); \ - const double munit_tmp_b_ = (b); \ - const double munit_tmp_diff_ = ((munit_tmp_a_ - munit_tmp_b_) < 0) ? \ - -(munit_tmp_a_ - munit_tmp_b_) : \ - (munit_tmp_a_ - munit_tmp_b_); \ - if (MUNIT_UNLIKELY(munit_tmp_diff_ > 1e-##precision)) { \ - munit_errorf("assertion failed: %s == %s (%0." #precision "g == %0." #precision "g)", \ - #a, #b, munit_tmp_a_, munit_tmp_b_); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_double_equal(a, b, precision) \ + do { \ + const double munit_tmp_a_ = (a); \ + const double munit_tmp_b_ = (b); \ + const double munit_tmp_diff_ = ((munit_tmp_a_ - munit_tmp_b_) < 0) ? \ + -(munit_tmp_a_ - munit_tmp_b_) : \ + (munit_tmp_a_ - munit_tmp_b_); \ + if (MUNIT_UNLIKELY(munit_tmp_diff_ > 1e-##precision)) { \ + munit_errorf("assertion failed: %s == %s (%0." #precision \ + "g == %0." #precision "g)", \ + #a, #b, munit_tmp_a_, munit_tmp_b_); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ #include -#define munit_assert_string_equal(a, b) \ - do { \ - const char* munit_tmp_a_ = a; \ - const char* munit_tmp_b_ = b; \ - if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) != 0)) { \ - munit_errorf("assertion failed: string %s == %s (\"%s\" == \"%s\")", \ - #a, #b, munit_tmp_a_, munit_tmp_b_); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_string_equal(a, b) \ + do { \ + const char *munit_tmp_a_ = a; \ + const char *munit_tmp_b_ = b; \ + if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) != 0)) { \ + munit_errorf( \ + "assertion failed: string %s == %s (\"%s\" == \"%s\")", #a, \ + #b, munit_tmp_a_, munit_tmp_b_); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_string_not_equal(a, b) \ - do { \ - const char* munit_tmp_a_ = a; \ - const char* munit_tmp_b_ = b; \ - if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) == 0)) { \ - munit_errorf("assertion failed: string %s != %s (\"%s\" == \"%s\")", \ - #a, #b, munit_tmp_a_, munit_tmp_b_); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_string_not_equal(a, b) \ + do { \ + const char *munit_tmp_a_ = a; \ + const char *munit_tmp_b_ = b; \ + if (MUNIT_UNLIKELY(strcmp(munit_tmp_a_, munit_tmp_b_) == 0)) { \ + munit_errorf( \ + "assertion failed: string %s != %s (\"%s\" == \"%s\")", #a, \ + #b, munit_tmp_a_, munit_tmp_b_); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_memory_equal(size, a, b) \ - do { \ - const unsigned char* munit_tmp_a_ = (const unsigned char*) (a); \ - const unsigned char* munit_tmp_b_ = (const unsigned char*) (b); \ - const size_t munit_tmp_size_ = (size); \ - if (MUNIT_UNLIKELY(memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) != 0) { \ - size_t munit_tmp_pos_; \ - for (munit_tmp_pos_ = 0 ; munit_tmp_pos_ < munit_tmp_size_ ; munit_tmp_pos_++) { \ - if (munit_tmp_a_[munit_tmp_pos_] != munit_tmp_b_[munit_tmp_pos_]) { \ - munit_errorf("assertion failed: memory %s == %s, at offset %" MUNIT_SIZE_MODIFIER "u", \ - #a, #b, munit_tmp_pos_); \ - break; \ - } \ - } \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_memory_equal(size, a, b) \ + do { \ + const unsigned char *munit_tmp_a_ = (const unsigned char *)(a); \ + const unsigned char *munit_tmp_b_ = (const unsigned char *)(b); \ + const size_t munit_tmp_size_ = (size); \ + if (MUNIT_UNLIKELY( \ + memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) != 0) { \ + size_t munit_tmp_pos_; \ + for (munit_tmp_pos_ = 0; munit_tmp_pos_ < munit_tmp_size_; \ + munit_tmp_pos_++) { \ + if (munit_tmp_a_[munit_tmp_pos_] != \ + munit_tmp_b_[munit_tmp_pos_]) { \ + munit_errorf( \ + "assertion failed: memory %s == %s, at offset %" MUNIT_SIZE_MODIFIER \ + "u", \ + #a, #b, munit_tmp_pos_); \ + break; \ + } \ + } \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_memory_not_equal(size, a, b) \ - do { \ - const unsigned char* munit_tmp_a_ = (const unsigned char*) (a); \ - const unsigned char* munit_tmp_b_ = (const unsigned char*) (b); \ - const size_t munit_tmp_size_ = (size); \ - if (MUNIT_UNLIKELY(memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) == 0) { \ - munit_errorf("assertion failed: memory %s != %s (%zu bytes)", \ - #a, #b, munit_tmp_size_); \ - } \ - MUNIT_PUSH_DISABLE_MSVC_C4127_ \ - } while (0) \ - MUNIT_POP_DISABLE_MSVC_C4127_ +#define munit_assert_memory_not_equal(size, a, b) \ + do { \ + const unsigned char *munit_tmp_a_ = (const unsigned char *)(a); \ + const unsigned char *munit_tmp_b_ = (const unsigned char *)(b); \ + const size_t munit_tmp_size_ = (size); \ + if (MUNIT_UNLIKELY( \ + memcmp(munit_tmp_a_, munit_tmp_b_, munit_tmp_size_)) == 0) { \ + munit_errorf("assertion failed: memory %s != %s (%zu bytes)", #a, \ + #b, munit_tmp_size_); \ + } \ + MUNIT_PUSH_DISABLE_MSVC_C4127_ \ + } while (0) MUNIT_POP_DISABLE_MSVC_C4127_ -#define munit_assert_ptr_equal(a, b) \ - munit_assert_ptr(a, ==, b) -#define munit_assert_ptr_not_equal(a, b) \ - munit_assert_ptr(a, !=, b) -#define munit_assert_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) +#define munit_assert_ptr_equal(a, b) munit_assert_ptr(a, ==, b) +#define munit_assert_ptr_not_equal(a, b) munit_assert_ptr(a, !=, b) +#define munit_assert_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 ***/ -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) \ - munit_malloc_ex(__FILE__, __LINE__, (size)) +#define munit_malloc(size) munit_malloc_ex(__FILE__, __LINE__, (size)) -#define munit_new(type) \ - ((type*) munit_malloc(sizeof(type))) +#define munit_new(type) ((type *)munit_malloc(sizeof(type))) -#define munit_calloc(nmemb, size) \ - munit_malloc((nmemb) * (size)) +#define munit_calloc(nmemb, size) munit_malloc((nmemb) * (size)) -#define munit_newa(type, nmemb) \ - ((type*) munit_calloc((nmemb), sizeof(type))) +#define munit_newa(type, nmemb) ((type *)munit_calloc((nmemb), sizeof(type))) /*** Random number generation ***/ @@ -398,69 +389,71 @@ void munit_rand_seed(munit_uint32_t seed); munit_uint32_t munit_rand_uint32(void); int munit_rand_int_range(int min, int max); 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 ***/ typedef enum { - /* Test successful */ - MUNIT_OK, - /* Test failed */ - MUNIT_FAIL, - /* Test was skipped */ - MUNIT_SKIP, - /* Test failed due to circumstances not intended to be tested - * (things like network errors, invalid parameter value, failure to - * allocate memory in the test harness, etc.). */ - MUNIT_ERROR + /* Test successful */ + MUNIT_OK, + /* Test failed */ + MUNIT_FAIL, + /* Test was skipped */ + MUNIT_SKIP, + /* Test failed due to circumstances not intended to be tested + * (things like network errors, invalid parameter value, failure to + * allocate memory in the test harness, etc.). */ + MUNIT_ERROR } MunitResult; typedef struct { - char* name; - char** values; + char *name; + char **values; } MunitParameterEnum; typedef struct { - char* name; - char* value; + char *name; + char *value; } 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 { - MUNIT_TEST_OPTION_NONE = 0, - MUNIT_TEST_OPTION_SINGLE_ITERATION = 1 << 0, - MUNIT_TEST_OPTION_TODO = 1 << 1 + MUNIT_TEST_OPTION_NONE = 0, + MUNIT_TEST_OPTION_SINGLE_ITERATION = 1 << 0, + MUNIT_TEST_OPTION_TODO = 1 << 1 } MunitTestOptions; -typedef MunitResult (* MunitTestFunc)(const MunitParameter params[], void* user_data_or_fixture); -typedef void* (* MunitTestSetup)(const MunitParameter params[], void* user_data); -typedef void (* MunitTestTearDown)(void* fixture); +typedef MunitResult ( + *MunitTestFunc)(const MunitParameter params[], void *user_data_or_fixture); +typedef void *(*MunitTestSetup)(const MunitParameter params[], void *user_data); +typedef void (*MunitTestTearDown)(void *fixture); typedef struct { - char* name; - MunitTestFunc test; - MunitTestSetup setup; - MunitTestTearDown tear_down; - MunitTestOptions options; - MunitParameterEnum* parameters; + char *name; + MunitTestFunc test; + MunitTestSetup setup; + MunitTestTearDown tear_down; + MunitTestOptions options; + MunitParameterEnum *parameters; } MunitTest; -typedef enum { - MUNIT_SUITE_OPTION_NONE = 0 -} MunitSuiteOptions; +typedef enum { MUNIT_SUITE_OPTION_NONE = 0 } MunitSuiteOptions; typedef struct MunitSuite_ MunitSuite; struct MunitSuite_ { - char* prefix; - MunitTest* tests; - MunitSuite* suites; - unsigned int iterations; - MunitSuiteOptions options; + char *prefix; + MunitTest *tests; + MunitSuite *suites; + unsigned int iterations; + 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 * 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; struct MunitArgument_ { - char* name; - munit_bool (* parse_argument)(const MunitSuite* suite, void* user_data, int* arg, int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)]); - void (* write_help)(const MunitArgument* argument, void* user_data); + char *name; + munit_bool (*parse_argument)(const MunitSuite *suite, 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, - void* user_data, - int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)], - const MunitArgument arguments[]); +int munit_suite_main_custom(const MunitSuite *suite, void *user_data, int argc, + char *const argv[MUNIT_ARRAY_PARAM(argc + 1)], + const MunitArgument arguments[]); #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_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_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_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_not_equal(a, b) munit_assert_ptr_not_equal(a, b) #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) */ #if defined(MUNIT_ENABLE_ASSERT_ALIASES) -# if defined(assert) -# undef assert -# endif -# define assert(expr) munit_assert(expr) +#if defined(assert) +#undef assert +#endif +#define assert(expr) munit_assert(expr) #endif diff --git a/tests/scale.c b/tests/scale.c deleted file mode 100644 index 7efd936..0000000 --- a/tests/scale.c +++ /dev/null @@ -1,5 +0,0 @@ - -static MunitTest scale_tests[] = { - { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } -}; - diff --git a/tests/test.c b/tests/test.c index 0517adb..bf0aaf9 100644 --- a/tests/test.c +++ b/tests/test.c @@ -7,8 +7,10 @@ * details. */ +#define MUNIT_NO_FORK (1) #define MUNIT_ENABLE_ASSERT_ALIASES (1) +#include #include #define __SL_DEBUG 0 @@ -119,7 +121,265 @@ uint32_key_cmp(sl_node *a, sl_node *b, void *aux) 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[] = { { (char *)"/api/insert", test_api_insert, test_api_insert_setup, 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 } }; -#include "mt.c" -#include "scale.c" -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 MunitTest mt_tests[] = { { NULL, NULL, NULL, NULL, + MUNIT_TEST_OPTION_NONE, NULL } }; -static const MunitSuite main_test_suite = { - (char *)"/api", api_test_suite,other_test_suite, 1, MUNIT_SUITE_OPTION_NONE -}; +static MunitTest scale_tests[] = { { NULL, NULL, NULL, NULL, + 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 main(int argc, char *argv[MUNIT_ARRAY_PARAM(argc + 1)])