diff options
| author | Phil Nash | 2012-08-14 19:30:30 +0100 |
|---|---|---|
| committer | Phil Nash | 2012-08-14 19:30:30 +0100 |
| commit | ddfe963623789fcf4e2f93163b0c5f97847d6c45 (patch) | |
| tree | 8ac01649f7ff702cd6fcbf12aacc2d253fd23f23 /include | |
| parent | 9c6ce97f01745d23bc48ca497698f4a30e8feba2 (diff) | |
| download | catch3-ddfe963623789fcf4e2f93163b0c5f97847d6c45.tar.gz | |
Split imll from TestCaseInfo
Diffstat (limited to 'include')
| -rw-r--r-- | include/catch.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_impl.hpp | 1 | ||||
| -rw-r--r-- | include/internal/catch_objc.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_runner_impl.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_running_test.hpp | 2 | ||||
| -rw-r--r-- | include/internal/catch_test_case_info.h | 75 | ||||
| -rw-r--r-- | include/internal/catch_test_case_info.hpp | 145 | ||||
| -rw-r--r-- | include/internal/catch_test_case_registry_impl.hpp | 2 |
8 files changed, 135 insertions, 96 deletions
diff --git a/include/catch.hpp b/include/catch.hpp index 1064ddd7..d03fdfbb 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -27,7 +27,7 @@ // These files are included here so the single_include script doesn't put them // in the conditionally compiled sections -#include "internal/catch_test_case_info.hpp" +#include "internal/catch_test_case_info.h" #include "internal/catch_interfaces_runner.h" #ifdef __OBJC__ diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 6bb11e77..f185476f 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -20,6 +20,7 @@ #include "catch_generators_impl.hpp" #include "catch_resultinfo.hpp" #include "catch_resultinfo_builder.hpp" +#include "catch_test_case_info.hpp" namespace Catch { NonCopyable::~NonCopyable() {} diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index ad13e295..fabfda8f 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -17,7 +17,7 @@ // NB. Any general catch headers included here must be included // in catch.hpp first to make sure they are included by the single // header for non obj-usage -#include "internal/catch_test_case_info.hpp" +#include "internal/catch_test_case_info.h" /////////////////////////////////////////////////////////////////////////////// // This protocol is really only here for (self) documenting purposes, since diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 15b60743..11603b69 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -13,7 +13,7 @@ #include "catch_interfaces_exception.h" #include "catch_config.hpp" #include "catch_test_registry.hpp" -#include "catch_test_case_info.hpp" +#include "catch_test_case_info.h" #include "catch_capture.hpp" #include "catch_totals.hpp" #include "catch_running_test.hpp" diff --git a/include/internal/catch_running_test.hpp b/include/internal/catch_running_test.hpp index 80cd6e12..25689f68 100644 --- a/include/internal/catch_running_test.hpp +++ b/include/internal/catch_running_test.hpp @@ -8,7 +8,7 @@ #ifndef TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED #define TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED -#include "catch_test_case_info.hpp" +#include "catch_test_case_info.h" #include "catch_section_info.hpp" namespace Catch { diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h new file mode 100644 index 00000000..6f6527d3 --- /dev/null +++ b/include/internal/catch_test_case_info.h @@ -0,0 +1,75 @@ +/* + * Created by Phil on 29/10/2010. + * 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_TESTCASEINFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_TESTCASEINFO_H_INCLUDED + +#include "catch_common.h" + +#include <string> + +namespace Catch { + + struct ITestCase; + + class TestCaseInfo { + public: + TestCaseInfo(); + + TestCaseInfo( ITestCase* testCase, + const char* name, + const char* description, + const SourceLineInfo& lineInfo ); + + + TestCaseInfo( const TestCaseInfo& other, const std::string& name ); + + void invoke() const; + const std::string& getName() const; + const std::string& getDescription() const; + const SourceLineInfo& getLineInfo() const; + bool isHidden() const; + + void swap( TestCaseInfo& other ); + bool operator == ( const TestCaseInfo& other ) const; + bool operator < ( const TestCaseInfo& other ) const; + + private: + Ptr<ITestCase> m_test; + std::string m_name; + std::string m_description; + SourceLineInfo m_lineInfo; + }; + + /////////////////////////////////////////////////////////////////////////// + + class TestSpec { + public: + TestSpec( const std::string& rawSpec ) + : m_rawSpec( rawSpec ), + m_isWildcarded( false ) { + + if( m_rawSpec[m_rawSpec.size()-1] == '*' ) { + m_rawSpec = m_rawSpec.substr( 0, m_rawSpec.size()-1 ); + m_isWildcarded = true; + } + } + + bool matches ( const std::string& testName ) const { + if( !m_isWildcarded ) + return m_rawSpec == testName; + else + return testName.size() >= m_rawSpec.size() && testName.substr( 0, m_rawSpec.size() ) == m_rawSpec; + } + + private: + std::string m_rawSpec; + bool m_isWildcarded; + }; +} + +#endif // TWOBLUECUBES_CATCH_TESTCASEINFO_H_INCLUDED diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index c54ae02e..ab6ec782 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -1,6 +1,6 @@ /* - * Created by Phil on 29/10/2010. - * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * Created by Phil on 14/08/2012. + * Copyright 2012 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,105 +8,68 @@ #ifndef TWOBLUECUBES_CATCH_TESTCASEINFO_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TESTCASEINFO_HPP_INCLUDED -#include "catch_common.h" +#include "catch_test_case_info.h" #include "catch_interfaces_testcase.h" -#include <map> -#include <string> namespace Catch { - class TestCaseInfo { - public: - TestCaseInfo( ITestCase* testCase, - const char* name, - const char* description, - const SourceLineInfo& lineInfo ) - : m_test( testCase ), - m_name( name ), - m_description( description ), - m_lineInfo( lineInfo ) - {} + TestCaseInfo::TestCaseInfo( ITestCase* testCase, + const char* name, + const char* description, + const SourceLineInfo& lineInfo ) + : m_test( testCase ), + m_name( name ), + m_description( description ), + m_lineInfo( lineInfo ) + {} - TestCaseInfo() - : m_test( NULL ), - m_name(), - m_description() - {} - - TestCaseInfo( const TestCaseInfo& other, const std::string& name ) - : m_test( other.m_test ), - m_name( name ), - m_description( other.m_description ), - m_lineInfo( other.m_lineInfo ) - {} + TestCaseInfo::TestCaseInfo() + : m_test( NULL ), + m_name(), + m_description() + {} - void invoke() const { - m_test->invoke(); - } - - const std::string& getName() const { - return m_name; - } + TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name ) + : m_test( other.m_test ), + m_name( name ), + m_description( other.m_description ), + m_lineInfo( other.m_lineInfo ) + {} - const std::string& getDescription() const { - return m_description; - } + void TestCaseInfo::invoke() const { + m_test->invoke(); + } - const SourceLineInfo& getLineInfo() const { - return m_lineInfo; - } + const std::string& TestCaseInfo::getName() const { + return m_name; + } - bool isHidden() const { - return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/'; - } - - void swap( TestCaseInfo& other ) { - m_test.swap( other.m_test ); - m_name.swap( other.m_name ); - m_description.swap( other.m_description ); - m_lineInfo.swap( other.m_lineInfo ); - } - - bool operator == ( const TestCaseInfo& other ) const { - return m_test.get() == other.m_test.get() && m_name == other.m_name; - } - - bool operator < ( const TestCaseInfo& other ) const { - return m_name < other.m_name; - } + const std::string& TestCaseInfo::getDescription() const { + return m_description; + } - private: - Ptr<ITestCase> m_test; - std::string m_name; - std::string m_description; - SourceLineInfo m_lineInfo; - }; - - /////////////////////////////////////////////////////////////////////////// - - class TestSpec { - public: - TestSpec( const std::string& rawSpec ) - : m_rawSpec( rawSpec ), - m_isWildcarded( false ) { - - if( m_rawSpec[m_rawSpec.size()-1] == '*' ) { - m_rawSpec = m_rawSpec.substr( 0, m_rawSpec.size()-1 ); - m_isWildcarded = true; - } - } - - bool matches ( const std::string& testName ) const { - if( !m_isWildcarded ) - return m_rawSpec == testName; - else - return testName.size() >= m_rawSpec.size() && testName.substr( 0, m_rawSpec.size() ) == m_rawSpec; - } - - private: - std::string m_rawSpec; - bool m_isWildcarded; - }; + const SourceLineInfo& TestCaseInfo::getLineInfo() const { + return m_lineInfo; + } + + bool TestCaseInfo::isHidden() const { + return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/'; + } + + void TestCaseInfo::swap( TestCaseInfo& other ) { + m_test.swap( other.m_test ); + m_name.swap( other.m_name ); + m_description.swap( other.m_description ); + m_lineInfo.swap( other.m_lineInfo ); + } + + bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const { + return m_test.get() == other.m_test.get() && m_name == other.m_name; + } + + bool TestCaseInfo::operator < ( const TestCaseInfo& other ) const { + return m_name < other.m_name; + } } #endif // TWOBLUECUBES_CATCH_TESTCASEINFO_HPP_INCLUDED diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index 62398dce..10202f64 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -6,7 +6,7 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #include "catch_test_registry.hpp" -#include "catch_test_case_info.hpp" +#include "catch_test_case_info.h" #include "catch_context.h" #include <vector> |