Debian Codegraph @

src/external/catch2/tests/SelfTest/IntrospectiveTests/TestSpecParser.tests.cpp

raw
1
2 // Copyright Catch2 Authors
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.txt or copy at
5 // https://www.boost.org/LICENSE_1_0.txt)
6
7 // SPDX-License-Identifier: BSL-1.0
8
9 #include <catch2/catch_test_macros.hpp>
10 #include <catch2/generators/catch_generators.hpp>
11 #include <catch2/catch_test_case_info.hpp>
12 #include <catch2/internal/catch_tag_alias_registry.hpp>
13 #include <catch2/internal/catch_test_spec_parser.hpp>
14
15 namespace {
16 static constexpr Catch::SourceLineInfo dummySourceLineInfo = CATCH_INTERNAL_LINEINFO;
17
18 static Catch::TestSpec parseAndCreateSpec(std::string const& str) {
19 Catch::TagAliasRegistry registry;
20 Catch::TestSpecParser parser( registry );
21
22 parser.parse( str );
23 auto spec = parser.testSpec();
24 REQUIRE( spec.hasFilters() );
25 REQUIRE( spec.getInvalidSpecs().empty());
26
27 return spec;
28 }
29
30 }
31
32 TEST_CASE( "Parsing tags with non-alphabetical characters is pass-through",
33 "[test-spec][test-spec-parser]" ) {
34 auto const& tagString = GENERATE( as<std::string>{},
35 "[tag with spaces]",
36 "[I said \"good day\" sir!]" );
37 CAPTURE(tagString);
38
39 auto spec = parseAndCreateSpec( tagString );
40
41 Catch::TestCaseInfo testCase(
42 "", { "fake test name", tagString }, dummySourceLineInfo );
43
44 REQUIRE( spec.matches( testCase ) );
45 }
46
47 TEST_CASE("Parsed tags are matched case insensitive",
48 "[test-spec][test-spec-parser]") {
49 auto spec = parseAndCreateSpec( "[CASED tag]" );
50
51 Catch::TestCaseInfo testCase(
52 "", { "fake test name", "[cased TAG]" }, dummySourceLineInfo );
53
54 REQUIRE( spec.matches( testCase ) );
55 }