move xassert.h to assert/assert.h so it can be included as <assert.h> by prepending the assert/ dir to the include search path and use include_next to facilitate that. Removed -pedantic from C flags of examples because include_next is an extension.
This commit is contained in:
parent
88d3836926
commit
791742d885
|
@ -4,10 +4,12 @@ project(xtest C)
|
|||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED TRUE)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
|
||||
|
||||
add_compile_definitions(XTEST)
|
||||
|
||||
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/assert)
|
||||
|
||||
|
||||
add_executable(example-all xtest.c examples/all.c examples/parameterized.c examples/assertions.c examples/expect_assertions.c examples/fail.c examples/groups.c examples/float.c examples/source.c examples/source.h examples/skip.c)
|
||||
target_compile_definitions(example-all PRIVATE XTEST_ALL_EXAMPLES)
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#if defined(__GNUC__) || defined(__clang__) || defined(XTEST_USE_INCLUDE_NEXT)
|
||||
#include_next <assert.h>
|
||||
#else
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#define XTEST_XASSERT
|
||||
|
||||
#if defined(XTEST_XTEST_H) && !defined(XTEST_SOURCE)
|
||||
#error "do not include xtest.h and xassert.h at the same time. xassert.h should only be included from your source files and xtest.h should only be included from your test files."
|
||||
#endif
|
||||
|
||||
#if defined(XTEST) && (!defined(XTEST_XTEST_H) || defined(XTEST_SOURCE))
|
||||
#if defined(XTEST) && !defined(XTEST_XTEST_H)
|
||||
|
||||
void xtest_internal_assert(const char* file, int line, const char* func, const char* expr);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include <string.h>
|
||||
#include "source.h"
|
||||
#include "../xassert.h"
|
||||
#include <assert.h>
|
||||
|
||||
int ret_1() {
|
||||
return 1;
|
||||
|
|
5
xtest.c
5
xtest.c
|
@ -1,9 +1,6 @@
|
|||
#include <setjmp.h>
|
||||
|
||||
#define XTEST_SOURCE
|
||||
|
||||
#include "xtest.h"
|
||||
#include "xassert.h"
|
||||
#include <assert.h>
|
||||
|
||||
struct xtest_assert_info {
|
||||
const char *file;
|
||||
|
|
4
xtest.h
4
xtest.h
|
@ -1,8 +1,8 @@
|
|||
#ifndef XTEST_XTEST_H
|
||||
#define XTEST_XTEST_H
|
||||
|
||||
#if defined(XTEST_XASSERT) && !defined(XTEST_SOURCE)
|
||||
#error "do not include xtest.h and xassert.h at the same time. xassert.h should only be included from your source files and xtest.h should only be included from your test files."
|
||||
#if defined(XTEST_XASSERT)
|
||||
#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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue