Skip to content

Commit

Permalink
Add trivial tests for most test macros
Browse files Browse the repository at this point in the history
For every macro only a single parameter set is used. This needs to test
all parameter combinations that are allowed for catchorg#2092.
  • Loading branch information
norbertwenzel committed Dec 8, 2020
1 parent fac517d commit c36f951
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
9 changes: 5 additions & 4 deletions projects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(TEST_SOURCES
${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
${SELF_TEST_DIR}/UsageTests/Class.tests.cpp
${SELF_TEST_DIR}/UsageTests/CMakeCTestRegistration.tests.cpp
${SELF_TEST_DIR}/UsageTests/Compilation.tests.cpp
${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp
${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp
Expand Down Expand Up @@ -379,21 +380,21 @@ set_tests_properties(RunTests PROPERTIES
)

add_test(NAME ListTests COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
set_tests_properties(ListTests PROPERTIES
set_tests_properties(ListTests PROPERTIES
PASS_REGULAR_EXPRESSION "[0-9]+ test cases"
FAIL_REGULAR_EXPRESSION "Hidden Test"
)

add_test(NAME ListTags COMMAND $<TARGET_FILE:SelfTest> --list-tags)
set_tests_properties(ListTags PROPERTIES
PASS_REGULAR_EXPRESSION "[0-9]+ tags"
set_tests_properties(ListTags PROPERTIES
PASS_REGULAR_EXPRESSION "[0-9]+ tags"
FAIL_REGULAR_EXPRESSION "\\[\\.\\]")

add_test(NAME ListReporters COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
set_tests_properties(ListReporters PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:")

add_test(NAME ListTestNamesOnly COMMAND $<TARGET_FILE:SelfTest> --list-test-names-only)
set_tests_properties(ListTestNamesOnly PROPERTIES
set_tests_properties(ListTestNamesOnly PROPERTIES
PASS_REGULAR_EXPRESSION "Regex string matcher"
FAIL_REGULAR_EXPRESSION "Hidden Test")

Expand Down
72 changes: 72 additions & 0 deletions projects/SelfTest/UsageTests/CMakeCTestRegistration.tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "catch.hpp"

#include <tuple>

namespace { namespace CMakeCTestRegistrationTests {

static void testFunction(){}

struct FakeFixture
{
void fakeTest(){}
};
template<typename...> struct TemplateFixture{};
template<int> struct FixtureWithValue{};

template<typename> struct TemplateStruct{};
template<int> struct CompileTimeValue{};

using SimpleTestTypes = std::tuple<int>;


SCENARIO("scenario", "[cmake_integration]"){}

SCENARIO_METHOD(FakeFixture, "scenario_method", "[cmake_integration]"){}

TEMPLATE_TEST_CASE("template_test_case", "[cmake_integration]", int){}

TEMPLATE_TEST_CASE_SIG("template_test_case_sig", "[cmake_integration]", ((int V), V), 42){}

TEMPLATE_TEST_CASE_METHOD(TemplateFixture, "template_test_case_method", "[cmake_integration]", int){}

TEMPLATE_TEST_CASE_METHOD_SIG(FixtureWithValue,
"template_test_case_method_sig",
"[cmake_integration]",
((int V), V), 42)
{}

TEMPLATE_LIST_TEST_CASE("template_list_test_case", "[cmake_integration]", SimpleTestTypes){}

TEMPLATE_LIST_TEST_CASE_METHOD(TemplateFixture,
"template_list_test_case_method", "[cmake_integration]",
SimpleTestTypes)
{}

TEMPLATE_PRODUCT_TEST_CASE("template_product_test_case", "[cmake_integration]", TemplateStruct, int){}

TEMPLATE_PRODUCT_TEST_CASE_SIG("template_product_test_case_sig", "[cmake_integration]",
((int V), V), CompileTimeValue, 42)
{}

TEMPLATE_PRODUCT_TEST_CASE_METHOD(TemplateFixture,
"template_product_test_case_method",
"[cmake_integration]",
TemplateStruct, int)
{}

TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(TemplateFixture,
"template_product_test_case_method_sig", "[cmake_integration]",
((int V), V), CompileTimeValue, 42)
{}

TEST_CASE("test_case", "[cmake_integration]"){}

TEST_CASE_METHOD(FakeFixture, "test_case_method", "[cmake_integration]"){}

ANON_TEST_CASE(){}

METHOD_AS_TEST_CASE(FakeFixture::fakeTest, "method_as_test_case", "[cmake_integration]")

REGISTER_TEST_CASE(testFunction, "register_test_case", "[cmake_integration]")

}} // namespace CMakeCTestRegistrationTests

0 comments on commit c36f951

Please sign in to comment.