Merge branch 'master' of github.com:philsquared/Catch

This commit is contained in:
Phil Nash 2011-09-29 18:42:32 +01:00
commit 4094e7fe3d
14 changed files with 95 additions and 55 deletions

3
.gitignore vendored
View File

@ -7,4 +7,5 @@ Debug
Release Release
*.user *.user
*.xcuserstate *.xcuserstate
/Test/Test.xcodeproj/xcuserdata/ /Test/Test.xcodeproj/xcuserdata/
.DS_Store

View File

@ -28,6 +28,7 @@
#include "internal/catch_generators.hpp" #include "internal/catch_generators.hpp"
#include "internal/catch_interfaces_exception.h" #include "internal/catch_interfaces_exception.h"
#include "internal/catch_approx.hpp" #include "internal/catch_approx.hpp"
#include "internal/catch_test_case_info.hpp"
#ifdef __OBJC__ #ifdef __OBJC__
#include "internal/catch_objc.hpp" #include "internal/catch_objc.hpp"

View File

@ -527,7 +527,8 @@ public:
const char* expr = "", const char* expr = "",
bool isNot = false bool isNot = false
) )
: m_result( expr, isNot, filename, line, macroName ) : m_result( expr, isNot, filename, line, macroName ),
m_messageStream()
{} {}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -627,7 +628,7 @@ class ScopedInfo
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
ScopedInfo ScopedInfo
() () : m_oss()
{ {
Hub::getResultCapture().pushScopedInfo( this ); Hub::getResultCapture().pushScopedInfo( this );
} }

View File

@ -194,6 +194,7 @@ namespace Catch
return setErrorMode( m_command + " does not accept arguments" ); return setErrorMode( m_command + " does not accept arguments" );
m_config.setShowHelp( true ); m_config.setShowHelp( true );
break; break;
case modeError:
default: default:
break; break;
} }

View File

@ -38,6 +38,7 @@ namespace Catch
void operator = ( const NonCopyable& ); void operator = ( const NonCopyable& );
protected: protected:
NonCopyable(){} NonCopyable(){}
virtual ~NonCopyable() {}
}; };
typedef char NoType; typedef char NoType;

View File

@ -24,7 +24,14 @@ namespace Catch
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
ResultInfo ResultInfo
() ()
: m_line( 0 ), : m_macroName(),
m_filename(),
m_line( 0 ),
m_expr(),
m_lhs(),
m_rhs(),
m_op(),
m_message(),
m_result( ResultWas::Unknown ), m_result( ResultWas::Unknown ),
m_isNot( false ) m_isNot( false )
{} {}
@ -44,6 +51,8 @@ namespace Catch
m_filename( filename ), m_filename( filename ),
m_line( line ), m_line( line ),
m_expr( expr ), m_expr( expr ),
m_lhs(),
m_rhs(),
m_op( isNotExpression( expr ) ? "!" : "" ), m_op( isNotExpression( expr ) ? "!" : "" ),
m_message( message ), m_message( message ),
m_result( result ), m_result( result ),
@ -53,6 +62,11 @@ namespace Catch
m_expr = "!" + m_expr; m_expr = "!" + m_expr;
} }
///////////////////////////////////////////////////////////////////////////
virtual ~ResultInfo
()
{
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
bool ok bool ok
() ()

View File

@ -31,6 +31,8 @@ namespace Catch
std::size_t line std::size_t line
) )
: m_name( name ), : m_name( name ),
m_successes(0),
m_failures(0),
m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_successes, m_failures ) ) m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_successes, m_failures ) )
{ {
} }

View File

@ -42,7 +42,11 @@ namespace Catch
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
TestCaseInfo TestCaseInfo
() ()
: m_test( NULL ) : m_test( NULL ),
m_name(),
m_description(),
m_filename(),
m_line( 0 )
{ {
} }

View File

@ -211,6 +211,11 @@ namespace Catch
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
m_config.stream() << "failed with message: '" << resultInfo.getMessage() << "'"; m_config.stream() << "failed with message: '" << resultInfo.getMessage() << "'";
break; break;
case ResultWas::Unknown: // These cases are here to prevent compiler warnings
case ResultWas::Ok:
case ResultWas::FailureBit:
case ResultWas::ExpressionFailed:
case ResultWas::Exception:
default: default:
if( !resultInfo.hasExpression() ) if( !resultInfo.hasExpression() )
{ {

View File

@ -156,6 +156,10 @@ namespace Catch
case ResultWas::Ok: case ResultWas::Ok:
stats.m_element = "success"; stats.m_element = "success";
break; break;
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
case ResultWas::DidntThrowException:
default: default:
stats.m_element = "unknown"; stats.m_element = "unknown";
break; break;

View File

@ -153,6 +153,12 @@ namespace Catch
.writeText( resultInfo.getMessage() ); .writeText( resultInfo.getMessage() );
m_currentTestSuccess = false; m_currentTestSuccess = false;
break; break;
case ResultWas::Unknown:
case ResultWas::Ok:
case ResultWas::FailureBit:
case ResultWas::ExpressionFailed:
case ResultWas::Exception:
case ResultWas::DidntThrowException:
default: default:
break; break;
} }

View File

@ -385,28 +385,12 @@
SDKROOT = macosx10.6; SDKROOT = macosx10.6;
USER_HEADER_SEARCH_PATHS = ../../include; USER_HEADER_SEARCH_PATHS = ../../include;
WARNING_CFLAGS = ( WARNING_CFLAGS = (
"-Wfloat-equal", "-Winit-self",
"-Wundef", "-Wmissing-include-dirs",
"-Wshadow", "-Wswitch-enum",
"-Wpointer-arith", "-Wunused",
"-Wcast-qual", "-Wredundant-decls",
"-Wcast-align", "-Wsign-promo",
"-Wwrite-strings",
"-Wconversion",
"-Wsign-compare",
"-Wmissing-noreturn",
"-Wmissing-format-attribute",
"-Wpacked",
"-Winline",
"-Wdisabled-optimization",
"-Wctor-dtor-privacy",
"-Wnon-virtual-dtor",
"-Wreorder",
"-Wold-style-cast",
"-Woverloaded-virtual",
"-ffor-scope",
"-Wextra",
"-Wall",
); );
}; };
name = Debug; name = Debug;
@ -417,10 +401,19 @@
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO; PREBINDING = NO;
SDKROOT = macosx10.6; SDKROOT = macosx10.6;
USER_HEADER_SEARCH_PATHS = ../../include; USER_HEADER_SEARCH_PATHS = ../../include;
WARNING_CFLAGS = (
"-Winit-self",
"-Wmissing-include-dirs",
"-Wswitch-enum",
"-Wunused",
"-Wredundant-decls",
"-Wsign-promo",
);
}; };
name = Release; name = Release;
}; };

View File

@ -144,7 +144,14 @@
isa = PBXProject; isa = PBXProject;
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "OCTest" */; buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "OCTest" */;
compatibilityVersion = "Xcode 3.1"; compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
);
mainGroup = 08FB7794FE84155DC02AAC07 /* OCTest */; mainGroup = 08FB7794FE84155DC02AAC07 /* OCTest */;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";

View File

@ -1530,7 +1530,7 @@ public:
Expression Expression
( (
MutableResultInfo& result, MutableResultInfo& result,
const T& lhs T lhs
) )
: m_result( result ), : m_result( result ),
m_lhs( lhs ) m_lhs( lhs )
@ -1638,7 +1638,7 @@ public:
private: private:
MutableResultInfo& m_result; MutableResultInfo& m_result;
const T& m_lhs; T m_lhs;
}; };
template<typename LhsT> template<typename LhsT>
@ -1727,12 +1727,12 @@ public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>
Expression<T> operator->* Expression<const T&> operator->*
( (
const T & operand const T & operand
) )
{ {
Expression<T> expr( m_result, operand ); Expression<const T&> expr( m_result, operand );
return expr; return expr;
} }
@ -2553,30 +2553,6 @@ namespace Catch
} // end namespace Catch } // end namespace Catch
#ifdef __OBJC__
// #included from: internal/catch_objc.hpp
/*
* catch_objc.hpp
* Catch
*
* Created by Phil on 14/11/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)
*
*/
#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED
#import <objc/runtime.h>
#include <string>
// 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
// #included from: internal/catch_test_case_info.hpp // #included from: internal/catch_test_case_info.hpp
/* /*
@ -2804,6 +2780,30 @@ namespace Catch
} }
#ifdef __OBJC__
// #included from: internal/catch_objc.hpp
/*
* catch_objc.hpp
* Catch
*
* Created by Phil on 14/11/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)
*
*/
#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED
#import <objc/runtime.h>
#include <string>
// 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
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// This protocol is really only here for (self) documenting purposes, since // This protocol is really only here for (self) documenting purposes, since
// all its methods are optional. // all its methods are optional.