Skip to content

Commit

Permalink
t Add test that demos how QCOMPARE does not fail if called outside sl…
Browse files Browse the repository at this point in the history
…ot (#6)
  • Loading branch information
claremacrae committed Nov 10, 2020
1 parent 50933ee commit 024aefa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Catch2_Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/Catch2_Tests/QtMacroTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <catch2/catch.hpp>

#include <iostream>

#include <QTest>

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";
}

0 comments on commit 024aefa

Please sign in to comment.