First commit for GitHub

This commit is contained in:
Phil Nash
2010-11-09 23:24:00 +00:00
commit d80260001b
27 changed files with 2471 additions and 0 deletions

37
Test/ClassTests.cpp Normal file
View File

@@ -0,0 +1,37 @@
/*
* ClassTests.cpp
* Catch - Test
*
* Created by Phil on 09/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)
*
*/
#include "catch.hpp"
namespace
{
class TestClass
{
std::string s;
public:
TestClass()
: s( "hello" )
{}
void succeedingCase()
{
EXPECT( s == "hello" );
}
void failingCase()
{
EXPECT( s == "world" );
}
};
}
METHOD_AS_TEST_CASE( TestClass::succeedingCase, "succeeding/TestClass/succeedingCase", "A method based test run that succeeds" );
METHOD_AS_TEST_CASE( TestClass::failingCase, "failing/TestClass/failingCase", "A method based test run that fails" );

185
Test/ConditionTests.cpp Normal file
View File

@@ -0,0 +1,185 @@
/*
* ConditionTests.cpp
* Catch - Test
*
* Created by Phil on 08/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)
*
*/
#include "catch.hpp"
#include <string>
struct TestData
{
TestData()
: int_seven( 7 ),
str_hello( "hello" ),
float_nine_point_one( 9.1f ),
double_pi( 3.1415926535 )
{}
int int_seven;
std::string str_hello;
float float_nine_point_one;
double double_pi;
};
// These tests all use the CHECK macro, which continues if the specific test fails.
// This allows us to see all results, even if an earlier check fails - which is
// particularly important for the "should fail" checks
// Equality tests
TEST_CASE( "succeeding/conditions/equality", "Equality checks that should succeed" )
{
TestData data;
CHECK( data.int_seven == 7 );
CHECK( data.float_nine_point_one == Approx( 9.1f ) );
CHECK( data.double_pi == Approx( 3.1415926535 ) );
CHECK( data.str_hello == "hello" );
CHECK( data.str_hello.size() == 5 );
double x = 1.1 + 0.1 + 0.1;
CHECK( x == Approx( 1.3 ) );
}
TEST_CASE( "failing/conditions/equality", "Equality checks that should fail" )
{
TestData data;
CHECK( data.int_seven == 6 );
CHECK( data.int_seven == 8 );
CHECK( data.int_seven == 0 );
CHECK( data.float_nine_point_one == Approx( 9.11f ) );
CHECK( data.float_nine_point_one == Approx( 9.0f ) );
CHECK( data.float_nine_point_one == 1 );
CHECK( data.float_nine_point_one == 0 );
CHECK( data.double_pi == Approx( 3.1415 ) );
CHECK( data.str_hello == "goodbye" );
CHECK( data.str_hello == "hell" );
CHECK( data.str_hello == "hello1" );
CHECK( data.str_hello.size() == 6 );
double x = 1.1 + 0.1 + 0.1;
CHECK( x == Approx( 1.301 ) );
}
TEST_CASE( "succeeding/conditions/inequality", "Inequality checks that should succeed" )
{
TestData data;
CHECK( data.int_seven != 6 );
CHECK( data.int_seven != 8 );
CHECK( data.float_nine_point_one != Approx( 9.11f ) );
CHECK( data.float_nine_point_one != Approx( 9.0f ) );
CHECK( data.float_nine_point_one != 1 );
CHECK( data.float_nine_point_one != 0 );
CHECK( data.double_pi != Approx( 3.1415 ) );
CHECK( data.str_hello != "goodbye" );
CHECK( data.str_hello != "hell" );
CHECK( data.str_hello != "hello1" );
CHECK( data.str_hello.size() != 6 );
}
TEST_CASE( "failing/conditions/inequality", "Inequality checks that should fails" )
{
TestData data;
CHECK( data.int_seven != 7 );
CHECK( data.float_nine_point_one != Approx( 9.1f ) );
CHECK( data.double_pi != Approx( 3.1415926535 ) );
CHECK( data.str_hello != "hello" );
CHECK( data.str_hello.size() != 5 );
}
// Ordering comparison tests
TEST_CASE( "succeeding/conditions/ordered", "Ordering comparison checks that should succeed" )
{
TestData data;
CHECK( data.int_seven < 8 );
CHECK( data.int_seven > 6 );
CHECK( data.int_seven > 0 );
CHECK( data.int_seven > -1 );
CHECK( data.int_seven >= 7 );
CHECK( data.int_seven >= 6 );
CHECK( data.int_seven <= 7 );
CHECK( data.int_seven <= 8 );
CHECK( data.float_nine_point_one > 9 );
CHECK( data.float_nine_point_one < 10 );
CHECK( data.float_nine_point_one < 9.2 );
CHECK( data.str_hello <= "hello" );
CHECK( data.str_hello >= "hello" );
CHECK( data.str_hello < "hellp" );
CHECK( data.str_hello < "z" );
CHECK( data.str_hello > "hellm" );
CHECK( data.str_hello > "a" );
}
TEST_CASE( "failing/conditions/ordered", "Ordering comparison checks that should fail" )
{
TestData data;
CHECK( data.int_seven > 7 );
CHECK( data.int_seven < 7 );
CHECK( data.int_seven > 8 );
CHECK( data.int_seven < 6 );
CHECK( data.int_seven < 0 );
CHECK( data.int_seven < -1 );
CHECK( data.int_seven >= 8 );
CHECK( data.int_seven <= 6 );
CHECK( data.float_nine_point_one < 9 );
CHECK( data.float_nine_point_one > 10 );
CHECK( data.float_nine_point_one > 9.2 );
CHECK( data.str_hello > "hello" );
CHECK( data.str_hello < "hello" );
CHECK( data.str_hello > "hellp" );
CHECK( data.str_hello > "z" );
CHECK( data.str_hello < "hellm" );
CHECK( data.str_hello < "a" );
CHECK( data.str_hello >= "z" );
CHECK( data.str_hello <= "a" );
}
// Not (!) tests
TEST_CASE( "succeeding/conditions/not", "'Not' checks that should succeed" )
{
bool falseValue = false;
CHECK( !false );
CHECK_NOT( false );
CHECK( !falseValue );
CHECK_NOT( falseValue );
CHECK( !(1 == 2) );
CHECK_NOT( 1 == 2 );
}
TEST_CASE( "failing/conditions/not", "'Not' checks that should fail" )
{
bool trueValue = true;
CHECK( !true );
CHECK_NOT( true );
CHECK( !trueValue );
CHECK_NOT( trueValue );
CHECK( !(1 == 1) );
CHECK_NOT( 1 == 1 );
}

58
Test/ExceptionTests.cpp Normal file
View File

@@ -0,0 +1,58 @@
/*
* ExceptionTests.cpp
* Catch - Test
*
* Created by Phil on 09/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)
*
*/
#include "catch.hpp"
#include <string>
namespace
{
int thisThrows()
{
throw std::domain_error( "expected exception" );
}
int thisDoesntThrow()
{
return 0;
}
}
TEST_CASE( "succeeding/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
{
CHECK_THROWS_AS( thisThrows(), std::domain_error );
CHECK_NOTHROW( thisDoesntThrow() );
EXPECT_THROWS( thisThrows() );
}
TEST_CASE( "failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
{
CHECK_THROWS_AS( thisThrows(), std::string );
CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error );
CHECK_NOTHROW( thisThrows() );
}
TEST_CASE( "failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
{
throw std::domain_error( "unexpected exception" );
}
TEST_CASE( "succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" )
{
try
{
throw std::domain_error( "unexpected exception" );
}
catch(...)
{
}
}

24
Test/MessageTests.cpp Normal file
View File

@@ -0,0 +1,24 @@
/*
* MessageTests.cpp
* Catch - Test
*
* Created by Phil on 09/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)
*
*/
#include "catch.hpp"
TEST_CASE( "succeeding/message", "INFO and WARN do not abort tests" )
{
INFO( "this is a message" ); // This should output the message but continue
WARN( "this is a warning" ); // This should output the message but continue
}
TEST_CASE( "failing/message", "FAIL aborts the test" )
{
FAIL( "This is a failure" ); // This should output the message and abort
}

79
Test/Test.1 Normal file
View File

@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 02/11/2010 \" DATE
.Dt Test 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm Test,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner

View File

@@ -0,0 +1,271 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {
/* Begin PBXBuildFile section */
4AFC340C128099F5003A0C29 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC340B128099F5003A0C29 /* main.cpp */; };
4AFC38CD12887D80003A0C29 /* ConditionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */; };
4AFC3A9912893C56003A0C29 /* ExceptionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */; };
4AFC3AA912893E54003A0C29 /* MessageTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3AA812893E54003A0C29 /* MessageTests.cpp */; };
4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B0A12894114003A0C29 /* ClassTests.cpp */; };
4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */; };
8DD76F6A0486A84900D96B5E /* Test.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859E8B029090EE04C91782 /* Test.1 */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
8DD76F690486A84900D96B5E /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
8DD76F6A0486A84900D96B5E /* Test.1 in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
4AFC340B128099F5003A0C29 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
4AFC341512809A36003A0C29 /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_capture.hpp; path = ../internal/catch_capture.hpp; sourceTree = SOURCE_ROOT; };
4AFC341612809A36003A0C29 /* catch_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = catch_common.h; path = ../internal/catch_common.h; sourceTree = SOURCE_ROOT; };
4AFC341712809A36003A0C29 /* catch_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_registry.hpp; path = ../internal/catch_registry.hpp; sourceTree = SOURCE_ROOT; };
4AFC341812809A36003A0C29 /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_registry.hpp; path = ../internal/catch_reporter_registry.hpp; sourceTree = SOURCE_ROOT; };
4AFC341912809A36003A0C29 /* catch_resultinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_resultinfo.hpp; path = ../internal/catch_resultinfo.hpp; sourceTree = SOURCE_ROOT; };
4AFC341A12809A36003A0C29 /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner_impl.hpp; path = ../internal/catch_runner_impl.hpp; sourceTree = SOURCE_ROOT; };
4AFC341B12809A36003A0C29 /* catch_testcaseinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_testcaseinfo.hpp; path = ../internal/catch_testcaseinfo.hpp; sourceTree = SOURCE_ROOT; };
4AFC341C12809A45003A0C29 /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_default_main.hpp; path = ../catch_default_main.hpp; sourceTree = SOURCE_ROOT; };
4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_basic.hpp; path = ../catch_reporter_basic.hpp; sourceTree = SOURCE_ROOT; };
4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_xml.hpp; path = ../catch_reporter_xml.hpp; sourceTree = SOURCE_ROOT; };
4AFC341F12809A45003A0C29 /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_list.hpp; path = ../internal/catch_list.hpp; sourceTree = SOURCE_ROOT; };
4AFC342012809A45003A0C29 /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../catch.hpp; sourceTree = SOURCE_ROOT; };
4AFC346412809D41003A0C29 /* catch_commandline.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_commandline.hpp; path = ../internal/catch_commandline.hpp; sourceTree = SOURCE_ROOT; };
4AFC359B1281F00B003A0C29 /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_section.hpp; path = ../internal/catch_section.hpp; sourceTree = SOURCE_ROOT; };
4AFC38161284B387003A0C29 /* catch_runner.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner.hpp; path = ../catch_runner.hpp; sourceTree = SOURCE_ROOT; };
4AFC384F1287E33E003A0C29 /* catch_runnerconfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runnerconfig.hpp; path = ../catch_runnerconfig.hpp; sourceTree = SOURCE_ROOT; };
4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionTests.cpp; sourceTree = "<group>"; };
4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionTests.cpp; sourceTree = "<group>"; };
4AFC3AA812893E54003A0C29 /* MessageTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageTests.cpp; sourceTree = "<group>"; };
4AFC3B0A12894114003A0C29 /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassTests.cpp; sourceTree = "<group>"; };
4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrickyTests.cpp; sourceTree = "<group>"; };
8DD76F6C0486A84900D96B5E /* Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Test; sourceTree = BUILT_PRODUCTS_DIR; };
C6859E8B029090EE04C91782 /* Test.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Test.1; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8DD76F660486A84900D96B5E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
08FB7794FE84155DC02AAC07 /* Test */ = {
isa = PBXGroup;
children = (
08FB7795FE84155DC02AAC07 /* Source */,
C6859E8C029090F304C91782 /* Documentation */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
name = Test;
sourceTree = "<group>";
};
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
4AFC341312809A12003A0C29 /* Catch */,
4AFC340B128099F5003A0C29 /* main.cpp */,
4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */,
4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */,
4AFC3AA812893E54003A0C29 /* MessageTests.cpp */,
4AFC3B0A12894114003A0C29 /* ClassTests.cpp */,
4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */,
);
name = Source;
sourceTree = "<group>";
};
1AB674ADFE9D54B511CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8DD76F6C0486A84900D96B5E /* Test */,
);
name = Products;
sourceTree = "<group>";
};
4AFC341312809A12003A0C29 /* Catch */ = {
isa = PBXGroup;
children = (
4AFC342012809A45003A0C29 /* catch.hpp */,
4AFC341C12809A45003A0C29 /* catch_default_main.hpp */,
4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */,
4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */,
4AFC38161284B387003A0C29 /* catch_runner.hpp */,
4AFC341412809A1B003A0C29 /* Internal */,
);
name = Catch;
sourceTree = "<group>";
};
4AFC341412809A1B003A0C29 /* Internal */ = {
isa = PBXGroup;
children = (
4AFC341F12809A45003A0C29 /* catch_list.hpp */,
4AFC359B1281F00B003A0C29 /* catch_section.hpp */,
4AFC346412809D41003A0C29 /* catch_commandline.hpp */,
4AFC341512809A36003A0C29 /* catch_capture.hpp */,
4AFC341612809A36003A0C29 /* catch_common.h */,
4AFC341712809A36003A0C29 /* catch_registry.hpp */,
4AFC341812809A36003A0C29 /* catch_reporter_registry.hpp */,
4AFC341912809A36003A0C29 /* catch_resultinfo.hpp */,
4AFC341A12809A36003A0C29 /* catch_runner_impl.hpp */,
4AFC341B12809A36003A0C29 /* catch_testcaseinfo.hpp */,
4AFC384F1287E33E003A0C29 /* catch_runnerconfig.hpp */,
);
name = Internal;
sourceTree = "<group>";
};
C6859E8C029090F304C91782 /* Documentation */ = {
isa = PBXGroup;
children = (
C6859E8B029090EE04C91782 /* Test.1 */,
);
name = Documentation;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8DD76F620486A84900D96B5E /* Test */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Test" */;
buildPhases = (
8DD76F640486A84900D96B5E /* Sources */,
8DD76F660486A84900D96B5E /* Frameworks */,
8DD76F690486A84900D96B5E /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = Test;
productInstallPath = "$(HOME)/bin";
productName = Test;
productReference = 8DD76F6C0486A84900D96B5E /* Test */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "Test" */;
compatibilityVersion = "Xcode 3.1";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* Test */;
projectDirPath = "";
projectRoot = "";
targets = (
8DD76F620486A84900D96B5E /* Test */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
8DD76F640486A84900D96B5E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4AFC340C128099F5003A0C29 /* main.cpp in Sources */,
4AFC38CD12887D80003A0C29 /* ConditionTests.cpp in Sources */,
4AFC3A9912893C56003A0C29 /* ExceptionTests.cpp in Sources */,
4AFC3AA912893E54003A0C29 /* MessageTests.cpp in Sources */,
4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */,
4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
1DEB923208733DC60010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = Test;
};
name = Debug;
};
1DEB923308733DC60010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = Test;
};
name = Release;
};
1DEB923608733DC60010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Debug;
};
1DEB923708733DC60010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Test" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB923208733DC60010E9CD /* Debug */,
1DEB923308733DC60010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "Test" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB923608733DC60010E9CD /* Debug */,
1DEB923708733DC60010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
}

34
Test/TrickyTests.cpp Normal file
View File

@@ -0,0 +1,34 @@
/*
* TrickyTests.cpp
* Catch - Test
*
* Created by Phil on 09/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)
*
*/
#include "catch.hpp"
namespace Catch
{
template<>
std::string toString<std::pair<int, int> >( const std::pair<int, int>& value )
{
std::ostringstream oss;
oss << "std::pair( " << value.first << ", " << value.second << " )";
return oss.str();
}
}
TEST_CASE( "succeeding/Tricky", "Some tricky to parse tests" )
{
std::pair<int, int> aNicePair( 1, 2 );
// !TBD: would be nice if this could compile without the extra parentheses
EXPECT( (std::pair<int, int>( 1, 2 )) == aNicePair );
}

53
Test/main.cpp Normal file
View File

@@ -0,0 +1,53 @@
/*
* main.cpp
* Catch - Test
*
* Created by Phil on 22/10/2010.
* Copyright 2010 Two Blue Cubes Ltd
*
* 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)
*
*/
#include "catch.hpp"
#include "catch_runner.hpp"
// This code runs the meta tests and verifies that the failing ones failed and the successful ones succeeded
int main (int argc, char * const argv[])
{
using namespace Catch;
ReporterConfig reporterConfig( ReporterConfig::Include::SuccessfulResults );
BasicReporter reporter (reporterConfig );
Runner runner;
runner.setReporter( &reporter );
std::ostringstream ossSucceeding;
reporterConfig.setStreamBuf( ossSucceeding.rdbuf() );
runner.runMatching( "succeeding/*" );
std::string succeedingResults = ossSucceeding.str();
std::ostringstream ossFailing;
reporterConfig.setStreamBuf( ossFailing.rdbuf() );
runner.runMatching( "failing/*" );
std::string failingResults = ossFailing.str();
int result = 0;
if( succeedingResults.find( "failed" ) != std::string::npos )
{
std::cerr << "Some tests that should have succeeded failed:\n\n" << succeedingResults;
result = 1;
}
if( failingResults.find( "succeeded" ) != std::string::npos )
{
std::cerr << "Some tests that should have failed succeeded:\n\n" << failingResults;
result = 1;
}
if( result == 0 )
{
std::cout << "All tests completed successfully" << std::endl;
}
return result;
}