Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Add test for CATCH_CONFIG_DISABLE_STRINGIFICATION

Commit
f3972f06959e6e50d4415472f62b638128aa0e17
Author
Martin Hořeňovský ·
Parents
38e1731f6934

Files · Download .tar.gz

Changes

 projects/ExtraTests/CMakeLists.txt                 | 40 +++++++++++++++++-----
 projects/ExtraTests/ToDo.txt                       |  1 -
 projects/ExtraTests/X11-DisableStringification.cpp | 16 +++++++++
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/projects/ExtraTests/CMakeLists.txt b/projects/ExtraTests/CMakeLists.txt
index e78a4d49..cf8b6b25 100644
--- a/projects/ExtraTests/CMakeLists.txt
+++ b/projects/ExtraTests/CMakeLists.txt
@@ -17,13 +17,37 @@ set( SINGLE_INCLUDE_PATH ${CATCH_DIR}/single_include )
 
 
 add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
-add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
-set_tests_properties(FallbackStringifier PROPERTIES PASS_REGULAR_EXPRESSION "foo{} for: { !!! }")
-
+target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
 
-set_property( TARGET FallbackStringifier PROPERTY CXX_STANDARD 11 )
-set_property( TARGET FallbackStringifier PROPERTY CXX_STANDARD_REQUIRED ON )
-set_property( TARGET FallbackStringifier PROPERTY CXX_EXTENSIONS OFF )
+add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
+set_tests_properties(
+    FallbackStringifier
+  PROPERTIES
+    PASS_REGULAR_EXPRESSION "foo{} for: { !!! }"
+)
+
+
+add_executable(DisableStringification ${TESTS_DIR}/X11-DisableStringification.cpp)
+target_compile_definitions( DisableStringification PRIVATE CATCH_CONFIG_DISABLE_STRINGIFICATION )
+add_test(NAME CATCH_CONFIG_DISABLE_STRINGIFICATION COMMAND DisableStringification -r compact -s)
+set_tests_properties(
+    CATCH_CONFIG_DISABLE_STRINGIFICATION
+  PROPERTIES
+    PASS_REGULAR_EXPRESSION "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
+    FAIL_REGULAR_EXPRESSION  "Hidden{} == Hidden{}"
+)
+
+
+set( EXTRA_TEST_BINARIES
+    FallbackStringifier
+    DisableStringification
+)
+
+# Shared config
+foreach( test ${EXTRA_TEST_BINARIES} )
+    set_property( TARGET ${test} PROPERTY CXX_STANDARD 11 )
+    set_property( TARGET ${test} PROPERTY CXX_STANDARD_REQUIRED ON )
+    set_property( TARGET ${test} PROPERTY CXX_EXTENSIONS OFF )
+    target_include_directories( ${test} PRIVATE ${SINGLE_INCLUDE_PATH} )
+endforeach()
 
-target_include_directories( FallbackStringifier PRIVATE ${SINGLE_INCLUDE_PATH} )
-target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
diff --git a/projects/ExtraTests/ToDo.txt b/projects/ExtraTests/ToDo.txt
index 0f878bd1..ed5495bd 100644
--- a/projects/ExtraTests/ToDo.txt
+++ b/projects/ExtraTests/ToDo.txt
@@ -7,6 +7,5 @@ yet:
     CATCH_CONFIG_DISABLE_MATCHERS           // Do not compile Matchers in this compilation unit
     CATCH_CONFIG_POSIX_SIGNALS              // Enable handling POSIX signals
     CATCH_CONFIG_WINDOWS_CRTDBG             // Enable leak checking using Windows's CRT Debug Heap
-    CATCH_CONFIG_DISABLE_STRINGIFICATION    // Disable stringifying the original expression
     CATCH_CONFIG_DISABLE                    // Disables assertions and test case registration
     CATCH_CONFIG_DEFAULT_REPORTER
diff --git a/projects/ExtraTests/X11-DisableStringification.cpp b/projects/ExtraTests/X11-DisableStringification.cpp
new file mode 100644
index 00000000..7a93f6e2
--- /dev/null
+++ b/projects/ExtraTests/X11-DisableStringification.cpp
@@ -0,0 +1,16 @@
+// X11-DisableStringification.cpp
+// Test that stringification of original expression can be disabled
+// this is a workaround for VS 2017 issue with Raw String literal
+// and preprocessor token pasting. In other words, hopefully this test
+// will be deleted soon :-)
+
+#define CATCH_CONFIG_MAIN
+#include <catch2/catch.hpp>
+
+struct Hidden {};
+
+bool operator==(Hidden, Hidden) { return true; }
+
+TEST_CASE("DisableStringification") {
+    REQUIRE( Hidden{} == Hidden{} );
+}