2012-02-10 09:28:37 +01:00
|
|
|
//
|
|
|
|
// CatchOCTestCase.mm
|
|
|
|
// OCTest
|
|
|
|
//
|
|
|
|
// Created by Phil Nash on 13/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)
|
|
|
|
|
|
|
|
#import "CatchOCTestCase.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation TestFixture
|
|
|
|
|
|
|
|
|
|
|
|
-(void) setUp
|
|
|
|
{
|
|
|
|
obj = [[TestObj alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) tearDown
|
|
|
|
{
|
2012-03-17 19:20:06 +01:00
|
|
|
arcSafeRelease( obj );
|
2012-02-10 09:28:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
OC_TEST_CASE( "OCTest/test1", "This is a test case" )
|
|
|
|
{
|
|
|
|
REQUIRE( obj.int_val == 0 );
|
|
|
|
|
|
|
|
obj.int_val = 1;
|
|
|
|
|
|
|
|
REQUIRE( obj.int_val == 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
OC_TEST_CASE( "OCTest/test2", "This is another test case" )
|
|
|
|
{
|
|
|
|
REQUIRE( obj.int_val == 0 );
|
|
|
|
|
|
|
|
obj.int_val = 2;
|
|
|
|
|
|
|
|
REQUIRE( obj.int_val == 2 );
|
|
|
|
}
|
2012-03-17 19:20:06 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
template<typename T>
|
|
|
|
void useObject( const T& object ){}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void useObject( const T* object ){}
|
2012-02-10 09:28:37 +01:00
|
|
|
|
2012-03-04 22:18:46 +01:00
|
|
|
using namespace Catch::Matchers;
|
|
|
|
OC_TEST_CASE( "OCTest/matchers", "Matches work with OC types (NSString so far)" )
|
|
|
|
{
|
2012-03-14 21:04:50 +01:00
|
|
|
REQUIRE_THAT( @"This is a string", Equals( @"This is a string" ) );
|
2012-03-04 22:18:46 +01:00
|
|
|
REQUIRE_THAT( @"This is a string", Contains( @"is a" ) );
|
|
|
|
REQUIRE_THAT( @"This is a string", StartsWith( @"This" ) );
|
|
|
|
REQUIRE_THAT( @"This is a string", EndsWith( @"string" ) );
|
|
|
|
}
|
|
|
|
|
2012-02-10 09:28:37 +01:00
|
|
|
@end
|