2014-06-30 08:33:17 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 27/06/2014.
|
|
|
|
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "catch.hpp"
|
|
|
|
#include "internal/catch_tag_alias_registry.h"
|
|
|
|
|
2017-07-13 10:20:37 +02:00
|
|
|
TEST_CASE( "Tag alias can be registered against tag patterns" ) {
|
2014-06-30 08:33:17 +02:00
|
|
|
|
|
|
|
Catch::TagAliasRegistry registry;
|
|
|
|
|
|
|
|
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
|
|
|
|
2017-07-13 10:20:37 +02:00
|
|
|
SECTION( "The same tag alias can only be registered once" ) {
|
2014-06-30 08:33:17 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 10 ) );
|
|
|
|
FAIL( "expected exception" );
|
|
|
|
}
|
|
|
|
catch( std::exception& ex ) {
|
2017-08-09 13:10:14 +02:00
|
|
|
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
2014-06-30 08:33:17 +02:00
|
|
|
std::string what = ex.what();
|
2017-08-09 13:10:14 +02:00
|
|
|
using namespace Catch::Matchers;
|
2014-06-30 08:33:17 +02:00
|
|
|
CHECK_THAT( what, Contains( "[@zzz]" ) );
|
|
|
|
CHECK_THAT( what, Contains( "file" ) );
|
|
|
|
CHECK_THAT( what, Contains( "2" ) );
|
|
|
|
CHECK_THAT( what, Contains( "10" ) );
|
2017-08-09 13:10:14 +02:00
|
|
|
#endif
|
2014-06-30 08:33:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-13 10:20:37 +02:00
|
|
|
SECTION( "Tag aliases must be of the form [@name]" ) {
|
2014-06-30 08:33:17 +02:00
|
|
|
CHECK_THROWS( registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
|
|
|
CHECK_THROWS( registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
|
|
|
CHECK_THROWS( registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
|
|
|
CHECK_THROWS( registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
|
|
|
}
|
|
|
|
}
|
2019-03-29 10:48:56 +01:00
|
|
|
|
|
|
|
TEST_CASE("shortened hide tags are split apart") {
|
2019-11-04 21:35:57 +01:00
|
|
|
auto testcase = Catch::makeTestCaseInfo("", {"fake test name", "[.magic-tag]"}, CATCH_INTERNAL_LINEINFO);
|
|
|
|
REQUIRE_THAT(testcase->tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")));
|
2019-03-29 10:48:56 +01:00
|
|
|
}
|