diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5024ef4..0b246e6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,7 +4,7 @@ function(xtest_define_example NAME) if (NAME STREQUAL "all") target_compile_definitions(${TARGET_NAME} PRIVATE XTEST_ALL_EXAMPLES) endif () - target_compile_options(${TARGET_NAME} PRIVATE -Wall -pedantic) + target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic) endfunction() diff --git a/examples/assertions.c b/examples/assertions.c index e1b3e7c..4c2b512 100644 --- a/examples/assertions.c +++ b/examples/assertions.c @@ -2,7 +2,7 @@ #include "xtest.h" #include "source.h" -void test_assert(void *fixture, void **params) { +void test_assert() { int i1 = 1; int i2 = 1; int i3 = 2; @@ -32,7 +32,7 @@ void test_assert(void *fixture, void **params) { xtest_assert(ret_1()); } -void test_assert_is(void *fixture, void **params) { +void test_assert_is() { int i1 = 1; int i2 = 1; int i3 = 2; @@ -66,7 +66,7 @@ void test_assert_is(void *fixture, void **params) { xtest_assert_is_not(b1, b3); } -void test_assert_str_is(void *fixture, void **params) { +void test_assert_str_is() { const char *s1 = "ret_1"; const char *s2 = "ret_1"; const char *s3 = "bar"; @@ -75,7 +75,7 @@ void test_assert_str_is(void *fixture, void **params) { xtest_assert_str_is_not(s1, s3); } -void test_assert_mem_is(void *fixture, void **params) { +void test_assert_mem_is() { char m1[100]; char m2[100]; for (int i = 0; i < 100; ++i) { diff --git a/examples/parameterized.c b/examples/parameterized.c index 3533dad..6f7e17b 100644 --- a/examples/parameterized.c +++ b/examples/parameterized.c @@ -2,16 +2,16 @@ #include "xtest.h" #include "source.h" -void test_add(void *fixture, void **params) { +void test_add(XTEST_UNUSED void *fixture, void **params) { int a = xtest_get_param(int, 0, params); int b = xtest_get_param(int, 1, params); int result = a + b; xtest_assert_is(add(a, b), result); } -void test_str_equals(void *fixture, void **params) { - const char* s1 = xtest_get_param_ptr(const char*, 0, params); - const char* s2 = xtest_get_param_ptr(const char*, 1, params); +void test_str_equals(XTEST_UNUSED void *fixture, void **params) { + const char *s1 = xtest_get_param_ptr(const char*, 0, params); + const char *s2 = xtest_get_param_ptr(const char*, 1, params); if (str_equals(s1, s2)) { xtest_assert_str_is(s1, s2); } else { diff --git a/include/xtest/xtest.h b/include/xtest/xtest.h index dd013e4..737600f 100644 --- a/include/xtest/xtest.h +++ b/include/xtest/xtest.h @@ -5,6 +5,12 @@ #error "do not include xtest.h before assert.h. If your tests make use of standard library assertions, include first xtest.h and then assert.h" #endif +#if defined(__GNUC__) || defined(__clang__) +#define XTEST_UNUSED __attribute__((unused)) +#else +#define XTEST_UNUSED +#endif + #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0ca476..a9bf19f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(xtest xtest.c) target_compile_definitions(xtest PRIVATE XTEST) -target_compile_options(xtest PRIVATE -Wall -pedantic) +target_compile_options(xtest PRIVATE -Wall -Wextra -pedantic) target_include_directories(xtest PRIVATE ../extern/pcg ../include/xtest)