Split imll from TestCaseInfo

This commit is contained in:
Phil Nash 2012-08-14 19:30:30 +01:00
parent 9c6ce97f01
commit ddfe963623
9 changed files with 139 additions and 98 deletions

View File

@ -27,7 +27,7 @@
// These files are included here so the single_include script doesn't put them // These files are included here so the single_include script doesn't put them
// in the conditionally compiled sections // 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" #include "internal/catch_interfaces_runner.h"
#ifdef __OBJC__ #ifdef __OBJC__

View File

@ -20,6 +20,7 @@
#include "catch_generators_impl.hpp" #include "catch_generators_impl.hpp"
#include "catch_resultinfo.hpp" #include "catch_resultinfo.hpp"
#include "catch_resultinfo_builder.hpp" #include "catch_resultinfo_builder.hpp"
#include "catch_test_case_info.hpp"
namespace Catch { namespace Catch {
NonCopyable::~NonCopyable() {} NonCopyable::~NonCopyable() {}

View File

@ -17,7 +17,7 @@
// NB. Any general catch headers included here must be included // NB. Any general catch headers included here must be included
// in catch.hpp first to make sure they are included by the single // in catch.hpp first to make sure they are included by the single
// header for non obj-usage // 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 // This protocol is really only here for (self) documenting purposes, since

View File

@ -13,7 +13,7 @@
#include "catch_interfaces_exception.h" #include "catch_interfaces_exception.h"
#include "catch_config.hpp" #include "catch_config.hpp"
#include "catch_test_registry.hpp" #include "catch_test_registry.hpp"
#include "catch_test_case_info.hpp" #include "catch_test_case_info.h"
#include "catch_capture.hpp" #include "catch_capture.hpp"
#include "catch_totals.hpp" #include "catch_totals.hpp"
#include "catch_running_test.hpp" #include "catch_running_test.hpp"

View File

@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED #ifndef TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED
#define 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" #include "catch_section_info.hpp"
namespace Catch { namespace Catch {

View File

@ -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

View File

@ -1,6 +1,6 @@
/* /*
* Created by Phil on 29/10/2010. * Created by Phil on 14/08/2012.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
* *
* Distributed under the Boost Software License, Version 1.0. (See accompanying * 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) * 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 #ifndef TWOBLUECUBES_CATCH_TESTCASEINFO_HPP_INCLUDED
#define 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 "catch_interfaces_testcase.h"
#include <map>
#include <string>
namespace Catch { namespace Catch {
class TestCaseInfo { TestCaseInfo::TestCaseInfo( ITestCase* testCase,
public: const char* name,
TestCaseInfo( ITestCase* testCase, const char* description,
const char* name, const SourceLineInfo& lineInfo )
const char* description, : m_test( testCase ),
const SourceLineInfo& lineInfo ) m_name( name ),
: m_test( testCase ), m_description( description ),
m_name( name ), m_lineInfo( lineInfo )
m_description( description ), {}
m_lineInfo( lineInfo )
{}
TestCaseInfo() TestCaseInfo::TestCaseInfo()
: m_test( NULL ), : m_test( NULL ),
m_name(), m_name(),
m_description() m_description()
{} {}
TestCaseInfo( const TestCaseInfo& other, const std::string& name ) TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name )
: m_test( other.m_test ), : m_test( other.m_test ),
m_name( name ), m_name( name ),
m_description( other.m_description ), m_description( other.m_description ),
m_lineInfo( other.m_lineInfo ) m_lineInfo( other.m_lineInfo )
{} {}
void invoke() const { void TestCaseInfo::invoke() const {
m_test->invoke(); m_test->invoke();
} }
const std::string& getName() const { const std::string& TestCaseInfo::getName() const {
return m_name; return m_name;
} }
const std::string& getDescription() const { const std::string& TestCaseInfo::getDescription() const {
return m_description; return m_description;
} }
const SourceLineInfo& getLineInfo() const { const SourceLineInfo& TestCaseInfo::getLineInfo() const {
return m_lineInfo; return m_lineInfo;
} }
bool isHidden() const { bool TestCaseInfo::isHidden() const {
return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/'; return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/';
} }
void swap( TestCaseInfo& other ) { void TestCaseInfo::swap( TestCaseInfo& other ) {
m_test.swap( other.m_test ); m_test.swap( other.m_test );
m_name.swap( other.m_name ); m_name.swap( other.m_name );
m_description.swap( other.m_description ); m_description.swap( other.m_description );
m_lineInfo.swap( other.m_lineInfo ); m_lineInfo.swap( other.m_lineInfo );
} }
bool operator == ( const TestCaseInfo& other ) const { bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const {
return m_test.get() == other.m_test.get() && m_name == other.m_name; return m_test.get() == other.m_test.get() && m_name == other.m_name;
} }
bool operator < ( const TestCaseInfo& other ) const { bool TestCaseInfo::operator < ( const TestCaseInfo& other ) const {
return m_name < other.m_name; return m_name < other.m_name;
} }
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_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_TESTCASEINFO_HPP_INCLUDED

View File

@ -6,7 +6,7 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/ */
#include "catch_test_registry.hpp" #include "catch_test_registry.hpp"
#include "catch_test_case_info.hpp" #include "catch_test_case_info.h"
#include "catch_context.h" #include "catch_context.h"
#include <vector> #include <vector>

View File

@ -34,6 +34,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; }; 4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@ -82,7 +83,7 @@
4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_runner_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_runner_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_section.hpp; sourceTree = "<group>"; }; 4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_section.hpp; sourceTree = "<group>"; };
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_stream.hpp; sourceTree = "<group>"; }; 4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_stream.hpp; sourceTree = "<group>"; };
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; }; 4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_test_case_info.h; sourceTree = "<group>"; };
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_test_case_registry_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_test_case_registry_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4A6D0C63149B3E3D00DB3EAA /* catch_test_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_test_registry.hpp; sourceTree = "<group>"; }; 4A6D0C63149B3E3D00DB3EAA /* catch_test_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_test_registry.hpp; sourceTree = "<group>"; };
4A6D0C64149B3E3D00DB3EAA /* catch_xmlwriter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_xmlwriter.hpp; sourceTree = "<group>"; }; 4A6D0C64149B3E3D00DB3EAA /* catch_xmlwriter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_xmlwriter.hpp; sourceTree = "<group>"; };
@ -214,6 +215,7 @@
4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */, 4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */,
4A90B59D15D24FE900EF71BC /* catch_resultinfo.hpp */, 4A90B59D15D24FE900EF71BC /* catch_resultinfo.hpp */,
4A90B59E15D2521E00EF71BC /* catch_resultinfo_builder.hpp */, 4A90B59E15D2521E00EF71BC /* catch_resultinfo_builder.hpp */,
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */,
); );
name = impl; name = impl;
sourceTree = "<group>"; sourceTree = "<group>";
@ -254,7 +256,7 @@
children = ( children = (
4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */, 4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */,
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */, 4A6D0C51149B3E3D00DB3EAA /* catch_context.h */,
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.hpp */, 4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */, 4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */, 4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
4AB77CB81553BB3800857BF0 /* catch_running_test.hpp */, 4AB77CB81553BB3800857BF0 /* catch_running_test.hpp */,