Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-12-05 16:00:20 +0100
committerMartin Hořeňovský2019-12-05 16:00:20 +0100
commit0fea081ad1a678b379182930a3ec22a3e275dbf0 (patch)
tree3afa04ce6805d7a86e9c59f87ac68cb1d21eb8b2 /tests
parent90e2549cecc2e886d563b7a88e752c9b4104f798 (diff)
downloadcatch3-0fea081ad1a678b379182930a3ec22a3e275dbf0.tar.gz
Move tests from projects/ to tests/
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt259
-rw-r--r--tests/ExtraTests/CMakeLists.txt158
-rw-r--r--tests/ExtraTests/ToDo.txt11
-rw-r--r--tests/ExtraTests/X01-PrefixedMacros.cpp81
-rw-r--r--tests/ExtraTests/X02-DisabledMacros.cpp31
-rw-r--r--tests/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp23
-rw-r--r--tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp33
-rw-r--r--tests/ExtraTests/X10-FallbackStringifier.cpp23
-rw-r--r--tests/ExtraTests/X11-DisableStringification.cpp16
-rw-r--r--tests/ExtraTests/X20-BenchmarkingMacros.cpp133
-rw-r--r--tests/ExtraTests/X90-WindowsHeaderInclusion.cpp12
-rw-r--r--tests/SelfTest/Baselines/automake.std.approved.txt168
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt1794
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt1385
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt13221
-rw-r--r--tests/SelfTest/Baselines/console.swa4.approved.txt382
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt1712
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt1725
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt15802
-rw-r--r--tests/SelfTest/CompileTimePerfTests/10.tests.cpp13
-rw-r--r--tests/SelfTest/CompileTimePerfTests/100.tests.cpp13
-rw-r--r--tests/SelfTest/CompileTimePerfTests/All.tests.cpp15
-rw-r--r--tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp516
-rw-r--r--tests/SelfTest/IntrospectiveTests/Details.tests.cpp23
-rw-r--r--tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp337
-rw-r--r--tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp405
-rw-r--r--tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp206
-rw-r--r--tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp45
-rw-r--r--tests/SelfTest/IntrospectiveTests/String.tests.cpp150
-rw-r--r--tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp67
-rw-r--r--tests/SelfTest/IntrospectiveTests/Tag.tests.cpp53
-rw-r--r--tests/SelfTest/IntrospectiveTests/ToString.tests.cpp42
-rw-r--r--tests/SelfTest/IntrospectiveTests/Xml.tests.cpp114
-rw-r--r--tests/SelfTest/Misc/invalid-test-names.input1
-rw-r--r--tests/SelfTest/Misc/plain-old-tests.input2
-rw-r--r--tests/SelfTest/Misc/special-characters-in-file.input1
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_console_colour.cpp3
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_debugger.cpp2
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp2
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_option.cpp3
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_stream.cpp3
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp2
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_test_spec.cpp3
-rw-r--r--tests/SelfTest/SurrogateCpps/catch_xmlwriter.cpp4
-rw-r--r--tests/SelfTest/TestMain.cpp34
-rw-r--r--tests/SelfTest/UsageTests/Approx.tests.cpp215
-rw-r--r--tests/SelfTest/UsageTests/BDD.tests.cpp110
-rw-r--r--tests/SelfTest/UsageTests/Benchmark.tests.cpp130
-rw-r--r--tests/SelfTest/UsageTests/Class.tests.cpp137
-rw-r--r--tests/SelfTest/UsageTests/Compilation.tests.cpp230
-rw-r--r--tests/SelfTest/UsageTests/Condition.tests.cpp334
-rw-r--r--tests/SelfTest/UsageTests/Decomposition.tests.cpp39
-rw-r--r--tests/SelfTest/UsageTests/EnumToString.tests.cpp99
-rw-r--r--tests/SelfTest/UsageTests/Exception.tests.cpp210
-rw-r--r--tests/SelfTest/UsageTests/Generators.tests.cpp256
-rw-r--r--tests/SelfTest/UsageTests/Matchers.tests.cpp562
-rw-r--r--tests/SelfTest/UsageTests/Message.tests.cpp269
-rw-r--r--tests/SelfTest/UsageTests/Misc.tests.cpp487
-rw-r--r--tests/SelfTest/UsageTests/ToStringByte.tests.cpp15
-rw-r--r--tests/SelfTest/UsageTests/ToStringChrono.tests.cpp44
-rw-r--r--tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp210
-rw-r--r--tests/SelfTest/UsageTests/ToStringOptional.tests.cpp23
-rw-r--r--tests/SelfTest/UsageTests/ToStringPair.tests.cpp30
-rw-r--r--tests/SelfTest/UsageTests/ToStringTuple.tests.cpp47
-rw-r--r--tests/SelfTest/UsageTests/ToStringVariant.tests.cpp91
-rw-r--r--tests/SelfTest/UsageTests/ToStringVector.tests.cpp86
-rw-r--r--tests/SelfTest/UsageTests/ToStringWhich.tests.cpp193
-rw-r--r--tests/SelfTest/UsageTests/Tricky.tests.cpp404
-rw-r--r--tests/SelfTest/UsageTests/VariadicMacros.tests.cpp29
-rw-r--r--tests/SelfTest/WarnAboutNoTests.cmake19
-rw-r--r--tests/XCode/OCTest/OCTest.xcodeproj/project.pbxproj294
-rw-r--r--tests/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--tests/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist8
-rw-r--r--tests/XCode/OCTest/OCTest/CatchOCTestCase.h25
-rw-r--r--tests/XCode/OCTest/OCTest/CatchOCTestCase.mm87
-rw-r--r--tests/XCode/OCTest/OCTest/Main.mm2
-rw-r--r--tests/XCode/OCTest/OCTest/OCTest.179
-rw-r--r--tests/XCode/OCTest/OCTest/OCTest.mm28
-rw-r--r--tests/XCode/OCTest/OCTest/TestObj.h28
-rw-r--r--tests/XCode/OCTest/OCTest/TestObj.m25
-rw-r--r--tests/XCode/OCTest/catch_objc_impl.mm69
81 files changed, 43949 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 00000000..a66b009c
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,259 @@
+include(MiscFunctions)
+
+####
+# Temporary workaround for VS toolset changes in 2017
+# We need to disable <UseFullPaths> property, but CMake doesn't support it
+# until 3.13 (not yet released)
+####
+if (MSVC)
+configure_file(${CATCH_DIR}/misc/SelfTest.vcxproj.user
+ ${CMAKE_BINARY_DIR}/tests
+ COPYONLY)
+endif(MSVC) #Temporary workaround
+
+
+# define the sources of the self test
+# Please keep these ordered alphabetically
+set(TEST_SOURCES
+ ${SELF_TEST_DIR}/TestMain.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/Details.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/GeneratorsImpl.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/InternalBenchmark.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/RandomNumberGeneration.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/Tag.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
+ ${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/Compilation.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/EnumToString.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Exception.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Generators.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Message.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Misc.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringByte.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringChrono.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringOptional.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringVariant.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/VariadicMacros.tests.cpp
+ ${SELF_TEST_DIR}/UsageTests/Matchers.tests.cpp
+ )
+CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
+
+# A set of impl files that just #include a single header
+# Please keep these ordered alphabetically
+set(SURROGATE_SOURCES
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
+ ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp
+ )
+CheckFileList(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps)
+
+
+# Specify the headers, too, so CLion recognises them as project files
+set(HEADERS
+ ${TOP_LEVEL_HEADERS}
+ ${EXTERNAL_HEADERS}
+ ${INTERNAL_HEADERS}
+ ${REPORTER_HEADERS}
+ ${BENCHMARK_HEADERS}
+ ${BENCHMARK_SOURCES}
+)
+
+# Provide some groupings for IDEs
+#SOURCE_GROUP("benchmark" FILES ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES})
+#SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
+#SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES})
+
+include(CTest)
+
+add_executable(SelfTest ${TEST_SOURCES})
+target_link_libraries(SelfTest PRIVATE Catch2)
+
+# It took CMake until 3.8 to abandon the doomed approach of enumerating
+# required features so we just list bunch of C++11 and C++14 features.
+target_compile_features(SelfTest
+ PRIVATE
+ cxx_alignas
+ cxx_alignof
+ cxx_attributes
+ cxx_auto_type
+ cxx_constexpr
+ cxx_defaulted_functions
+ cxx_deleted_functions
+ cxx_final
+ cxx_lambdas
+ cxx_noexcept
+ cxx_override
+ cxx_range_for
+ cxx_rvalue_references
+ cxx_static_assert
+ cxx_strong_enums
+ cxx_trailing_return_types
+ cxx_unicode_literals
+ cxx_user_literals
+ cxx_variadic_macros
+ cxx_variable_templates
+)
+
+
+if (CATCH_ENABLE_COVERAGE)
+ set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
+ find_package(codecov)
+ add_coverage(SelfTest)
+ list(APPEND LCOV_REMOVE_PATTERNS "'/usr/*'")
+ coverage_evaluate()
+endif()
+
+# Add per compiler options
+if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
+ target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Wpedantic -Wmissing-declarations )
+ if (CATCH_ENABLE_WERROR)
+ target_compile_options( SelfTest PRIVATE -Werror )
+ endif()
+endif()
+# Clang specific options go here
+if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
+ target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
+endif()
+if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
+ STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level
+ target_compile_options( SelfTest PRIVATE /w44265 /w44061 /w44062 /w45038 )
+ if (CATCH_ENABLE_WERROR)
+ target_compile_options( SelfTest PRIVATE /WX)
+ endif()
+ # Force MSVC to consider everything as encoded in utf-8
+ target_compile_options( SelfTest PRIVATE /utf-8 )
+endif()
+
+
+# configure unit tests via CTest
+add_test(NAME RunTests COMMAND $<TARGET_FILE:SelfTest>)
+set_tests_properties(RunTests PROPERTIES
+ FAIL_REGULAR_EXPRESSION "Filters:"
+)
+
+# Because CTest does not allow us to check both return code _and_ expected
+# output in one test, we run these commands twice. First time we check
+# the output, the second time we check the exit code.
+add_test(NAME List::Tests::Output COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
+set_tests_properties(List::Tests::Output PROPERTIES
+ PASS_REGULAR_EXPRESSION "[0-9]+ test cases"
+ FAIL_REGULAR_EXPRESSION "Hidden Test"
+)
+add_test(NAME List::Tests::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
+add_test(NAME List::Tests::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high -r xml)
+set_tests_properties(List::Tests::XmlOutput PROPERTIES
+ PASS_REGULAR_EXPRESSION "<Line>[0-9]+</Line>"
+ FAIL_REGULAR_EXPRESSION "[0-9]+ test cases"
+)
+
+add_test(NAME List::Tags::Output COMMAND $<TARGET_FILE:SelfTest> --list-tags)
+set_tests_properties(List::Tags::Output PROPERTIES
+ PASS_REGULAR_EXPRESSION "[0-9]+ tags"
+ FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
+add_test(NAME List::Tags::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-tags)
+add_test(NAME List::Tags::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-tags -r xml)
+set_tests_properties(List::Tags::XmlOutput PROPERTIES
+ PASS_REGULAR_EXPRESSION "<Count>18</Count>"
+ FAIL_REGULAR_EXPRESSION "[0-9]+ tags"
+)
+
+
+add_test(NAME List::Reporters::Output COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
+set_tests_properties(List::Reporters::Output PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:")
+add_test(NAME List::Reporters::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
+add_test(NAME List::Reporters::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-reporters -r xml)
+set_tests_properties(List::Reporters::XmlOutput PROPERTIES
+ PASS_REGULAR_EXPRESSION "<Name>compact</Name>"
+ FAIL_REGULAR_EXPRESSION "Available reporters:"
+)
+
+
+
+add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions)
+set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case")
+
+add_test(NAME NoTest COMMAND $<TARGET_FILE:SelfTest> Tracker, "___nonexistent_test___")
+set_tests_properties(NoTest PROPERTIES
+ PASS_REGULAR_EXPRESSION "No test cases matched '___nonexistent_test___'"
+ FAIL_REGULAR_EXPRESSION "No tests ran"
+)
+
+add_test(NAME WarnAboutNoTests COMMAND ${CMAKE_COMMAND} -P ${SELF_TEST_DIR}/WarnAboutNoTests.cmake $<TARGET_FILE:SelfTest>)
+
+add_test(NAME UnmatchedOutputFilter COMMAND $<TARGET_FILE:SelfTest> [this-tag-does-not-exist] -w NoTests)
+set_tests_properties(UnmatchedOutputFilter
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "No test cases matched '\\[this-tag-does-not-exist\\]'"
+)
+
+add_test(NAME FilteredSection-1 COMMAND $<TARGET_FILE:SelfTest> \#1394 -c RunSection)
+set_tests_properties(FilteredSection-1 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
+add_test(NAME FilteredSection-2 COMMAND $<TARGET_FILE:SelfTest> \#1394\ nested -c NestedRunSection -c s1)
+set_tests_properties(FilteredSection-2 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
+
+# AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable
+add_test(NAME ApprovalTests COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/scripts/approvalTests.py $<TARGET_FILE:SelfTest>)
+set_tests_properties(ApprovalTests PROPERTIES FAIL_REGULAR_EXPRESSION "Results differed")
+
+add_test(NAME RegressionCheck-1670 COMMAND $<TARGET_FILE:SelfTest> "#1670 regression check" -c A -r compact)
+set_tests_properties(RegressionCheck-1670 PROPERTIES PASS_REGULAR_EXPRESSION "Passed 1 test case with 2 assertions.")
+
+add_test(NAME VersionCheck COMMAND $<TARGET_FILE:SelfTest> -h)
+set_tests_properties(VersionCheck PROPERTIES PASS_REGULAR_EXPRESSION "Catch v${PROJECT_VERSION}")
+
+add_test(NAME LibIdentityTest COMMAND $<TARGET_FILE:SelfTest> --libidentify)
+set_tests_properties(LibIdentityTest PROPERTIES PASS_REGULAR_EXPRESSION "description: A Catch2 test executable")
+
+add_test(NAME FilenameAsTagsTest COMMAND $<TARGET_FILE:SelfTest> -\# --list-tags)
+set_tests_properties(FilenameAsTagsTest PROPERTIES PASS_REGULAR_EXPRESSION "\\[#Approx.tests\\]")
+
+add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
+set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
+
+add_test(NAME NegativeSpecNoHiddenTests COMMAND $<TARGET_FILE:SelfTest> --list-tests ~[approval])
+set_tests_properties(NegativeSpecNoHiddenTests PROPERTIES FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
+
+add_test(NAME TestsInFile::SimpleSpecs COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/plain-old-tests.input")
+set_tests_properties(TestsInFile::SimpleSpecs PROPERTIES PASS_REGULAR_EXPRESSI