Skip to content

Commit

Permalink
Fixed usage of method on uninitialized class in tpunit and removed -W…
Browse files Browse the repository at this point in the history
…no-uninitialized for tests.
  • Loading branch information
FranckRJ committed Apr 27, 2024
1 parent a3c7448 commit e2cc030
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_link_libraries(FakeIt_tests PRIVATE
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
target_compile_options(FakeIt_tests PRIVATE -Wall -Wextra -Wno-ignored-qualifiers -Wno-uninitialized -O0 -g3)
target_compile_options(FakeIt_tests PRIVATE -Wall -Wextra -Wno-ignored-qualifiers -O0 -g3)
elseif(MSVC)
target_compile_options(FakeIt_tests PRIVATE /W3 /sdl /Od)
endif()
Expand Down
16 changes: 9 additions & 7 deletions tests/tpunit++.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@
* used by all test functions.
* TEST(function); registers a function to run as a test within a test fixture.
*/
#define AFTER(M) tpunit_detail_method(&M, #M, method::AFTER_METHOD)
#define AFTER_CLASS(M) tpunit_detail_method(&M, #M, method::AFTER_CLASS_METHOD)
#define BEFORE(M) tpunit_detail_method(&M, #M, method::BEFORE_METHOD)
#define BEFORE_CLASS(M) tpunit_detail_method(&M, #M, method::BEFORE_CLASS_METHOD)
#define TEST(M) tpunit_detail_method(&M, #M, method::TEST_METHOD)
#define AFTER(M) tpunit_detail_method(this, &M, #M, method::AFTER_METHOD)
#define AFTER_CLASS(M) tpunit_detail_method(this, &M, #M, method::AFTER_CLASS_METHOD)
#define BEFORE(M) tpunit_detail_method(this, &M, #M, method::BEFORE_METHOD)
#define BEFORE_CLASS(M) tpunit_detail_method(this, &M, #M, method::BEFORE_CLASS_METHOD)
#define TEST(M) tpunit_detail_method(this, &M, #M, method::TEST_METHOD)

/**
* Try our best to detect compiler support for exception handling so
Expand Down Expand Up @@ -297,12 +297,14 @@ namespace tpunit {
/**
* Create a new method to register with the test fixture.
*
* @param[in] obj The test fixture for which the new method will be registered.
* @param[in] _method A method to register with the test fixture.
* @param[in] _name The internal name of the method used when status messages are displayed.
* @param[in] _type The type of method to register.
*/
template <typename C>
method* tpunit_detail_method(void (C::*_method)(), const char* _name, unsigned char _type) {
return new method(this, static_cast<void (TestFixture::*)()>(_method), _name, _type);
static method* tpunit_detail_method(TestFixture* obj, void (C::*_method)(), const char* _name, unsigned char _type) {
return new method(obj, static_cast<void (TestFixture::*)()>(_method), _name, _type);
}

/**
Expand Down

0 comments on commit e2cc030

Please sign in to comment.