added -Wextra and fixed resulting warnings
This commit is contained in:
parent
fcc5557d55
commit
29b2185728
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 <string.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue