mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Tag aliases feature
This commit is contained in:
39
projects/SelfTest/TagAliasTests.cpp
Normal file
39
projects/SelfTest/TagAliasTests.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||
|
||||
Catch::TagAliasRegistry registry;
|
||||
|
||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
||||
|
||||
SECTION( "The same tag alias can only be registered once", "" ) {
|
||||
|
||||
try {
|
||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 10 ) );
|
||||
FAIL( "expected exception" );
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
std::string what = ex.what();
|
||||
CHECK_THAT( what, Contains( "[@zzz]" ) );
|
||||
CHECK_THAT( what, Contains( "file" ) );
|
||||
CHECK_THAT( what, Contains( "2" ) );
|
||||
CHECK_THAT( what, Contains( "10" ) );
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "Tag aliases must be of the form [@name]", "" ) {
|
||||
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 ) ) );
|
||||
}
|
||||
}
|
@@ -9,11 +9,17 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
|
||||
// Some example tag aliases
|
||||
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
|
||||
CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
|
||||
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
|
||||
|
||||
template<size_t size>
|
||||
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
|
||||
|
Reference in New Issue
Block a user