diff options
| author | Phil Nash | 2014-05-16 18:28:58 +0100 |
|---|---|---|
| committer | Phil Nash | 2014-05-16 18:28:58 +0100 |
| commit | b1e7d161b5fc92bebc465cf2a16e918b1e20a385 (patch) | |
| tree | 6af749a4dea3b4225eb04bfce67ef709b02a8811 /include | |
| parent | ae75b3774aba58fbd1f71711cbdc81286bf65aeb (diff) | |
| download | catch3-b1e7d161b5fc92bebc465cf2a16e918b1e20a385.tar.gz | |
Moved catch_test_spec.h to catch_test_spec.hpp
Diffstat (limited to 'include')
| -rw-r--r-- | include/catch_runner.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_runner_impl.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_test_case_info.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_test_case_registry_impl.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_test_spec.h | 118 | ||||
| -rw-r--r-- | include/internal/catch_test_spec.hpp | 111 | ||||
| -rw-r--r-- | include/internal/catch_test_spec_parser.hpp | 2 |
7 files changed, 112 insertions, 127 deletions
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index 2cc883f3..3e1e42b2 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -11,7 +11,7 @@ #include "internal/catch_commandline.hpp" #include "internal/catch_list.hpp" #include "internal/catch_runner_impl.hpp" -#include "internal/catch_test_spec.h" +#include "internal/catch_test_spec.hpp" #include "internal/catch_version.h" #include "internal/catch_text.h" diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 9794bc51..1eca9d51 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -16,7 +16,7 @@ #include "catch_test_case_info.h" #include "catch_capture.hpp" #include "catch_totals.hpp" -#include "catch_test_spec.h" +#include "catch_test_spec.hpp" #include "catch_test_case_tracker.hpp" #include "catch_timer.h" diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index c3cb6a53..bbd2a902 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -8,7 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED -#include "catch_test_spec.h" +#include "catch_test_spec.hpp" #include "catch_test_case_info.h" #include "catch_interfaces_testcase.h" #include "catch_tags.h" diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index a0a478ff..ecffa2e5 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -10,7 +10,7 @@ #include "catch_test_registry.hpp" #include "catch_test_case_info.h" -#include "catch_test_spec.h" +#include "catch_test_spec.hpp" #include "catch_context.h" #include <vector> diff --git a/include/internal/catch_test_spec.h b/include/internal/catch_test_spec.h deleted file mode 100644 index 7af4a89e..00000000 --- a/include/internal/catch_test_spec.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Created by Phil on 14/8/2012. - * Copyright 2010 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) - */ -#ifndef TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED -#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -#include "catch_test_case_info.h" - -#include <string> -#include <vector> - -namespace Catch { - - class TestSpec { - struct Pattern : SharedImpl<> { - virtual ~Pattern(); - virtual bool matches( TestCaseInfo const& testCase ) const = 0; - }; - class NamePattern : public Pattern { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) { - if( startsWith( m_name, "*" ) ) { - m_name = name.substr( 1 ); - m_wildcard = WildcardAtStart; - } - if( endsWith( m_name, "*" ) ) { - m_name = m_name.substr( 0, m_name.size()-1 ); - m_wildcard = (WildcardPosition)( m_wildcard | WildcardAtEnd ); - } - } - virtual ~NamePattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - switch( m_wildcard ) { - case NoWildcard: - return m_name == toLower( testCase.name ); - case WildcardAtStart: - return endsWith( toLower( testCase.name ), m_name ); - case WildcardAtEnd: - return startsWith( toLower( testCase.name ), m_name ); - case WildcardAtBothEnds: - return contains( toLower( testCase.name ), m_name ); - } - } - private: - std::string m_name; - WildcardPosition m_wildcard; - }; - class TagPattern : public Pattern { - public: - TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} - virtual ~TagPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return testCase.tags.find( m_tag ) != testCase.tags.end(); - } - private: - std::string m_tag; - }; - class ExcludedPattern : public Pattern { - public: - ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} - virtual ~ExcludedPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } - private: - Ptr<Pattern> m_underlyingPattern; - }; - - struct Filter { - std::vector<Ptr<Pattern> > m_patterns; - - bool matches( TestCaseInfo const& testCase ) const { - // All patterns in a filter must match for the filter to be a match - for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) - if( !(*it)->matches( testCase ) ) - return false; - return true; - } - }; - - public: - bool hasFilters() const { - return !m_filters.empty(); - } - bool matches( TestCaseInfo const& testCase ) const { - // A TestSpec matches if any filter matches - for( std::vector<Filter>::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) - if( it->matches( testCase ) ) - return true; - return false; - } - - private: - std::vector<Filter> m_filters; - - friend class TestSpecParser; - }; -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif // TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED diff --git a/include/internal/catch_test_spec.hpp b/include/internal/catch_test_spec.hpp index 0827a938..762f263e 100644 --- a/include/internal/catch_test_spec.hpp +++ b/include/internal/catch_test_spec.hpp @@ -1,6 +1,6 @@ /* - * Created by Phil on 2/12/2013. - * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * Created by Phil on 14/8/2012. + * Copyright 2010 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) @@ -8,8 +8,111 @@ #ifndef TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED -#include "catch_test_spec.hpp" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif -// deprecated +#include "catch_test_case_info.h" + +#include <string> +#include <vector> + +namespace Catch { + + class TestSpec { + struct Pattern : SharedImpl<> { + virtual ~Pattern(); + virtual bool matches( TestCaseInfo const& testCase ) const = 0; + }; + class NamePattern : public Pattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) { + if( startsWith( m_name, "*" ) ) { + m_name = name.substr( 1 ); + m_wildcard = WildcardAtStart; + } + if( endsWith( m_name, "*" ) ) { + m_name = m_name.substr( 0, m_name.size()-1 ); + m_wildcard = (WildcardPosition)( m_wildcard | WildcardAtEnd ); + } + } + virtual ~NamePattern(); + virtual bool matches( TestCaseInfo const& testCase ) const { + switch( m_wildcard ) { + case NoWildcard: + return m_name == toLower( testCase.name ); + case WildcardAtStart: + return endsWith( toLower( testCase.name ), m_name ); + case WildcardAtEnd: + return startsWith( toLower( testCase.name ), m_name ); + case WildcardAtBothEnds: + return contains( toLower( testCase.name ), m_name ); + } + } + private: + std::string m_name; + WildcardPosition m_wildcard; + }; + class TagPattern : public Pattern { + public: + TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} + virtual ~TagPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const { + return testCase.tags.find( m_tag ) != testCase.tags.end(); + } + private: + std::string m_tag; + }; + class ExcludedPattern : public Pattern { + public: + ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} + virtual ~ExcludedPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } + private: + Ptr<Pattern> m_underlyingPattern; + }; + + struct Filter { + std::vector<Ptr<Pattern> > m_patterns; + + bool matches( TestCaseInfo const& testCase ) const { + // All patterns in a filter must match for the filter to be a match + for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) + if( !(*it)->matches( testCase ) ) + return false; + return true; + } + }; + + public: + bool hasFilters() const { + return !m_filters.empty(); + } + bool matches( TestCaseInfo const& testCase ) const { + // A TestSpec matches if any filter matches + for( std::vector<Filter>::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) + if( it->matches( testCase ) ) + return true; + return false; + } + + private: + std::vector<Filter> m_filters; + + friend class TestSpecParser; + }; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED diff --git a/include/internal/catch_test_spec_parser.hpp b/include/internal/catch_test_spec_parser.hpp index fd566813..6fc356e8 100644 --- a/include/internal/catch_test_spec_parser.hpp +++ b/include/internal/catch_test_spec_parser.hpp @@ -13,7 +13,7 @@ #pragma clang diagnostic ignored "-Wpadded" #endif -#include "catch_test_spec.h" +#include "catch_test_spec.hpp" namespace Catch { |