mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Split Option<T> and TagAlias definitions away from the main include path
This commit is contained in:
parent
918eca5ee9
commit
33fd54a673
@ -176,6 +176,7 @@ set(INTERNAL_HEADERS
|
||||
${HEADER_DIR}/internal/catch_string_manip.h
|
||||
${HEADER_DIR}/internal/catch_suppress_warnings.h
|
||||
${HEADER_DIR}/internal/catch_tag_alias.h
|
||||
${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.h
|
||||
${HEADER_DIR}/internal/catch_tag_alias_registry.h
|
||||
${HEADER_DIR}/internal/catch_test_case_info.h
|
||||
${HEADER_DIR}/internal/catch_test_case_registry_impl.hpp
|
||||
@ -223,6 +224,7 @@ set(IMPL_SOURCES
|
||||
${HEADER_DIR}/internal/catch_stringref.cpp
|
||||
${HEADER_DIR}/internal/catch_string_manip.cpp
|
||||
${HEADER_DIR}/internal/catch_tag_alias.cpp
|
||||
${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.cpp
|
||||
${HEADER_DIR}/internal/catch_tag_alias_registry.cpp
|
||||
${HEADER_DIR}/internal/catch_test_case_info.cpp
|
||||
${HEADER_DIR}/internal/catch_test_case_registry_impl.cpp
|
||||
|
@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#include "internal/catch_context.h"
|
||||
#include "internal/catch_tag_alias_autoregistrar.h"
|
||||
#include "internal/catch_test_registry.hpp"
|
||||
#include "internal/catch_capture.hpp"
|
||||
#include "internal/catch_section.h"
|
||||
|
@ -8,14 +8,16 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED
|
||||
|
||||
#include "catch_tag_alias.h"
|
||||
#include "catch_option.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct TagAlias;
|
||||
|
||||
struct ITagAliasRegistry {
|
||||
virtual ~ITagAliasRegistry();
|
||||
virtual Option<TagAlias> find( std::string const& alias ) const = 0;
|
||||
// Nullptr if not present
|
||||
virtual TagAlias const* find( std::string const& alias ) const = 0;
|
||||
virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0;
|
||||
|
||||
static ITagAliasRegistry const& get();
|
||||
|
5
include/internal/catch_tag_alias.cpp
Normal file
5
include/internal/catch_tag_alias.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "catch_tag_alias.h"
|
||||
|
||||
namespace Catch {
|
||||
TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {}
|
||||
}
|
@ -21,12 +21,6 @@ namespace Catch {
|
||||
SourceLineInfo lineInfo;
|
||||
};
|
||||
|
||||
struct RegistrarForTagAliases {
|
||||
RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED
|
||||
|
||||
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); }
|
||||
|
15
include/internal/catch_tag_alias_autoregistrar.cpp
Normal file
15
include/internal/catch_tag_alias_autoregistrar.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "catch_tag_alias_autoregistrar.h"
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) {
|
||||
try {
|
||||
getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo);
|
||||
} catch (...) {
|
||||
// Do not throw when constructing global objects, instead register the exception to be processed later
|
||||
getMutableRegistryHub().registerStartupException(std::current_exception());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
22
include/internal/catch_tag_alias_autoregistrar.h
Normal file
22
include/internal/catch_tag_alias_autoregistrar.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Created by Martin on 27/07/2017.
|
||||
*
|
||||
* 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)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED
|
||||
|
||||
#include "catch_common.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct RegistrarForTagAliases {
|
||||
RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); }
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED
|
@ -16,12 +16,12 @@ namespace Catch {
|
||||
|
||||
TagAliasRegistry::~TagAliasRegistry() {}
|
||||
|
||||
Option<TagAlias> TagAliasRegistry::find( std::string const& alias ) const {
|
||||
TagAlias const* TagAliasRegistry::find( std::string const& alias ) const {
|
||||
auto it = m_registry.find( alias );
|
||||
if( it != m_registry.end() )
|
||||
return it->second;
|
||||
return &(it->second);
|
||||
else
|
||||
return Option<TagAlias>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED
|
||||
|
||||
#include "catch_interfaces_tag_alias_registry.h"
|
||||
#include "catch_tag_alias.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -17,7 +18,7 @@ namespace Catch {
|
||||
class TagAliasRegistry : public ITagAliasRegistry {
|
||||
public:
|
||||
~TagAliasRegistry() override;
|
||||
Option<TagAlias> find( std::string const& alias ) const override;
|
||||
TagAlias const* find( std::string const& alias ) const override;
|
||||
std::string expandAliases( std::string const& unexpandedTestSpec ) const override;
|
||||
void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user