From 024aefae74a98a41d2ac72c2cb0ea14e8cfa06e1 Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Tue, 10 Nov 2020 08:56:40 +0000 Subject: [PATCH] t Add test that demos how QCOMPARE does not fail if called outside slot (#6) --- tests/Catch2_Tests/CMakeLists.txt | 1 + tests/Catch2_Tests/QtMacroTests.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/Catch2_Tests/QtMacroTests.cpp diff --git a/tests/Catch2_Tests/CMakeLists.txt b/tests/Catch2_Tests/CMakeLists.txt index 9db966a..3b24cdf 100644 --- a/tests/Catch2_Tests/CMakeLists.txt +++ b/tests/Catch2_Tests/CMakeLists.txt @@ -3,6 +3,7 @@ set(CMAKE_CXX_STANDARD 11) add_executable(${PROJECT_NAME} main.cpp ApprovalsQtTests.cpp + QtMacroTests.cpp integrations/catch/Catch2QtStringMakerTests.cpp ) target_link_libraries(${PROJECT_NAME} ApprovalTestsQt catch2) diff --git a/tests/Catch2_Tests/QtMacroTests.cpp b/tests/Catch2_Tests/QtMacroTests.cpp new file mode 100644 index 0000000..1fc2502 --- /dev/null +++ b/tests/Catch2_Tests/QtMacroTests.cpp @@ -0,0 +1,13 @@ +#include + +#include + +#include + +TEST_CASE("Demonstrate wrongly-passing QCOMPARE test"/*, "[!shouldfail]"*/) +{ + // https://github.com/approvals/ApprovalTests.cpp.Qt/issues/6 + std::cout << "before QCOMPARE\n"; + QCOMPARE(1, 2); // this will return, silently, as called from outside a slot + std::cout << "after QCOMPARE - this line will never be reached\n"; +}