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

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-04-04 11:54:02 +0200
committerMartin Hořeňovský2022-04-05 12:57:33 +0200
commitc045733d058c505c65ee83edff942f6e70c38411 (patch)
tree68996861d65d2078b3fdf38637e11cd483c6d35a /tests
parent9fea3d253fdaa074bf18951f9018a7a77a5e6a24 (diff)
downloadcatch3-c045733d058c505c65ee83edff942f6e70c38411.tar.gz
Add splitReporterSpec helper
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp46
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1c520120..a4d01dc9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -79,6 +79,7 @@ set(TEST_SOURCES
${SELF_TEST_DIR}/TestRegistrations.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Clara.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/CmdLineHelpers.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/ColourImpl.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Details.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/FloatingPoint.tests.cpp
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp
new file mode 100644
index 00000000..b79dcca2
--- /dev/null
+++ b/tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp
@@ -0,0 +1,46 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/internal/catch_reporter_spec_parser.hpp>
+#include <catch2/matchers/catch_matchers_vector.hpp>
+
+TEST_CASE("Reporter spec splitting", "[reporter-spec][cli][approvals]") {
+ using Catch::Detail::splitReporterSpec;
+ using Catch::Matchers::Equals;
+ using namespace std::string_literals;
+
+ SECTION("Various edge cases") {
+ REQUIRE_THAT( splitReporterSpec( "" ),
+ Equals( std::vector<std::string>{ ""s } ) );
+ REQUIRE_THAT( splitReporterSpec( "::" ),
+ Equals( std::vector<std::string>{ "", "" } ) );
+ REQUIRE_THAT( splitReporterSpec( "::rep" ),
+ Equals( std::vector<std::string>{ "", "rep" } ) );
+ REQUIRE_THAT( splitReporterSpec( "rep::" ),
+ Equals( std::vector<std::string>{ "rep", "" } ) );
+
+ }
+
+ SECTION("Validish specs") {
+ REQUIRE_THAT( splitReporterSpec( "newReporter" ),
+ Equals( std::vector<std::string>{ "newReporter"s } ) );
+ REQUIRE_THAT(
+ splitReporterSpec( "foo-reporter::key1=value1::key2=value with "
+ "space::key with space=some-value" ),
+ Equals(
+ std::vector<std::string>{ "foo-reporter"s,
+ "key1=value1"s,
+ "key2=value with space"s,
+ "key with space=some-value"s } ) );
+ REQUIRE_THAT(
+ splitReporterSpec( "spaced reporter name::key:key=value:value" ),
+ Equals( std::vector<std::string>{ "spaced reporter name"s,
+ "key:key=value:value"s } ) );
+ }
+}