Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions include/zeroerr/unittest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


#include "zeroerr/internal/config.h"
#include "zeroerr/assert.h"

#include "zeroerr/internal/time.h"
#include <iosfwd>
Expand Down Expand Up @@ -52,9 +53,10 @@ ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
{__VA_ARGS__})); \
inline void classname::funcname(ZEROERR_UNUSED(zeroerr::TestContext* _ZEROERR_TEST_CONTEXT))

#define TEST_CASE_FIXTURE(fixture, ...) \
ZEROERR_EXPAND(ZEROERR_CREATE_TEST_CLASS(fixture, ZEROERR_NAMEGEN(_zeroerr_class), \
ZEROERR_NAMEGEN(_zeroerr_test_method), __VA_ARGS__))
#define TEST_CASE_FIXTURE(fixture, ...) \
ZEROERR_EXPAND(ZEROERR_CREATE_TEST_CLASS(fixture, ZEROERR_NAMEGEN(ZEROERR_CAT(fixture, _zeroerr_class)), \
ZEROERR_NAMEGEN(ZEROERR_CAT(fixture, _zeroerr_test_method)), \
__VA_ARGS__))


#define ZEROERR_HAVE_SAME_OUTPUT _ZEROERR_TEST_CONTEXT->save_output();
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ foreach(order IN ITEMS zeroerr_first stl_first)
endif()
add_test(NAME PrintCapabilities_${order} COMMAND print_capabilities_${order})
endforeach()

add_subdirectory(native_fixture_identity)
15 changes: 15 additions & 0 deletions test/native_fixture_identity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.21)
project(NativeFixtureIdentity LANGUAGES C CXX)
include(CTest)
include(CheckIPOSupported)
check_ipo_supported(RESULT _ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${_ipo_supported})
set(_fixture_sources first.cpp second.cpp)
if(NOT TARGET zeroerr)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." zeroerr EXCLUDE_FROM_ALL)
target_compile_definitions(zeroerr PRIVATE ZEROERR_NO_MAIN)
list(APPEND _fixture_sources main.cpp)
endif()
add_executable(fixture_identity ${_fixture_sources})
target_link_libraries(fixture_identity PRIVATE zeroerr)
add_test(NAME fixture_identity COMMAND fixture_identity --no-color)
3 changes: 3 additions & 0 deletions test/native_fixture_identity/first.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <zeroerr/unittest.h>
struct FirstFixture { int value = 17; };
TEST_CASE_FIXTURE(FirstFixture, "native.fixture.first") { REQUIRE(value == 17); }
2 changes: 2 additions & 0 deletions test/native_fixture_identity/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <zeroerr/unittest.h>
int main(int argc, char** argv) { return zeroerr::UnitTest().parseArgs(argc, const_cast<const char**>(argv)).run(); }
3 changes: 3 additions & 0 deletions test/native_fixture_identity/second.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <zeroerr/unittest.h>
struct SecondFixture { char padding[128] = {}; int value = 91; };
TEST_CASE_FIXTURE(SecondFixture, "native.fixture.second") { REQUIRE(value == 91); }
8 changes: 5 additions & 3 deletions zeroerr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,7 @@ ZEROERR_SUPPRESS_COMMON_WARNINGS_POP




#include <iosfwd>
#include <functional>

Expand Down Expand Up @@ -3332,9 +3333,10 @@ ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
{__VA_ARGS__})); \
inline void classname::funcname(ZEROERR_UNUSED(zeroerr::TestContext* _ZEROERR_TEST_CONTEXT))

#define TEST_CASE_FIXTURE(fixture, ...) \
ZEROERR_EXPAND(ZEROERR_CREATE_TEST_CLASS(fixture, ZEROERR_NAMEGEN(_zeroerr_class), \
ZEROERR_NAMEGEN(_zeroerr_test_method), __VA_ARGS__))
#define TEST_CASE_FIXTURE(fixture, ...) \
ZEROERR_EXPAND(ZEROERR_CREATE_TEST_CLASS(fixture, ZEROERR_NAMEGEN(ZEROERR_CAT(fixture, _zeroerr_class)), \
ZEROERR_NAMEGEN(ZEROERR_CAT(fixture, _zeroerr_test_method)), \
__VA_ARGS__))


#define ZEROERR_HAVE_SAME_OUTPUT _ZEROERR_TEST_CONTEXT->save_output();
Expand Down
Loading