Permalink
Browse files

Merge pull request #38 from StevenEWright/master

Upgrades unit tests to XCTest and ARC.
  • Loading branch information...
2 parents 2dba13f + edf0b55 commit 73f2b8506a05722bf65a8f183334ed68ee0de726 @beelsebob committed Aug 8, 2015

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -7,7 +7,7 @@
//
#import <Foundation/Foundation.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#pragma mark General Assertions
@@ -17,53 +17,53 @@
#define CPSTAssertKindOfClass(obj, cls) \
do { \
id _obj = obj; \
- STAssertTrue([_obj isKindOfClass:[cls class]], @"Expecting a kind of class %@; got class %@ from object %@.", NSStringFromClass([_obj class]), NSStringFromClass([cls class]), _obj); \
+ XCTAssertTrue([_obj isKindOfClass:[cls class]], @"Expecting a kind of class %@; got class %@ from object %@.", NSStringFromClass([_obj class]), NSStringFromClass([cls class]), _obj); \
} while (0)
-#define _CPSTAssertKindOfClass_Unsafe(obj, cls) STAssertTrue([obj isKindOfClass:[cls class]], @"Expecting a kind of class %@; got class %@ from object %@.", NSStringFromClass([obj class]), NSStringFromClass([cls class]), obj);
+#define _CPSTAssertKindOfClass_Unsafe(obj, cls) XCTAssertTrue([obj isKindOfClass:[cls class]], @"Expecting a kind of class %@; got class %@ from object %@.", NSStringFromClass([obj class]), NSStringFromClass([cls class]), obj);
#pragma mark Token Assertions
#define CPSTAssertKeywordEquals(token, expectation) \
do { \
CPKeywordToken * t = (CPKeywordToken *)token; /* this escapes the potential multiple invocations of popToken */ \
_CPSTAssertKindOfClass_Unsafe(t, CPKeywordToken); \
- STAssertEqualObjects([t keyword], expectation, @"Keyword doesn't match expectation."); \
+ XCTAssertEqualObjects([t keyword], expectation, @"Keyword doesn't match expectation."); \
} while (0)
#define CPSTAssertIdentifierEquals(token, expectation) \
do { \
CPIdentifierToken * _t = (CPIdentifierToken *)token; \
_CPSTAssertKindOfClass_Unsafe(_t, CPIdentifierToken); \
- STAssertEqualObjects([_t identifier], expectation, @"Identifier doesn't match expectation."); \
+ XCTAssertEqualObjects([_t identifier], expectation, @"Identifier doesn't match expectation."); \
} while (0)
#define CPSTAssertIntegerNumberEquals(token, expectation) \
do { \
CPNumberToken * t = (CPNumberToken *)token; /* this escapes the potential multiple invocations of popToken */ \
_CPSTAssertKindOfClass_Unsafe(t, CPNumberToken); \
NSNumber * n = [t number]; \
- STAssertTrue(0==strcmp([n objCType], @encode(NSInteger)), @"Type expectation failure. Wanted %s, got %s.", @encode(NSInteger), [n objCType]); \
- STAssertEquals([n integerValue], ((NSInteger)expectation), @"Number fails expectation."); \
+ XCTAssertTrue(0==strcmp([n objCType], @encode(NSInteger)), @"Type expectation failure. Wanted %s, got %s.", @encode(NSInteger), [n objCType]); \
+ XCTAssertEqual([n integerValue], ((NSInteger)expectation), @"Number fails expectation."); \
} while (0)
#define CPSTAssertIntegerNumberEqualsWithAccuracy(token, expectation, accuracy) \
do { \
CPNumberToken * t = (CPNumberToken *)token; \
_CPSTAssertKindOfClass_Unsafe(t, CPNumberToken); \
NSNumber * n = [t number]; \
- STAssertTrue(0==strcmp([n objCType], @encode(NSInteger)), @"Type expectation failure. Wanted %s, got %s.", @encode(NSInteger), [n objCType]); \
- STAssertEqualsWithAccuracy([n integerValue], ((NSInteger)expectation), ((NSInteger)accuracy), @"Number fails expectation."); \
+ XCTAssertTrue(0==strcmp([n objCType], @encode(NSInteger)), @"Type expectation failure. Wanted %s, got %s.", @encode(NSInteger), [n objCType]); \
+ XCTAssertEqualWithAccuracy([n integerValue], ((NSInteger)expectation), ((NSInteger)accuracy), @"Number fails expectation."); \
} while (0)
#define CPSTAssertFloatingNumberEquals(token, expectation) \
do { \
CPNumberToken * t = (CPNumberToken *)token; \
_CPSTAssertKindOfClass_Unsafe(t, CPNumberToken); \
NSNumber * n = [t number]; \
- STAssertTrue(0==strcmp([n objCType], @encode(double)), @"Type expectation failure. Wanted %s, got %s.", @encode(double), [n objCType]); \
- STAssertEquals([n doubleValue], ((double)expectation), @"Number fails expectation."); \
+ XCTAssertTrue(0==strcmp([n objCType], @encode(double)), @"Type expectation failure. Wanted %s, got %s.", @encode(double), [n objCType]); \
+ XCTAssertEqual([n doubleValue], ((double)expectation), @"Number fails expectation."); \
} while (0)
#define CPSTAssertFloatingNumberEqualsWithAccuracy(token, expectation, accuracy) \
do { \
CPNumberToken * t = (CPNumberToken *)token; \
_CPSTAssertKindOfClass_Unsafe(t, CPNumberToken); \
NSNumber * n = [t number]; \
- STAssertTrue(0==strcmp([n objCType], @encode(double)), @"Type expectation failure. Wanted %s, got %s.", @encode(double), [n objCType]); \
- STAssertEqualsWithAccuracy([n doubleValue], ((double)expectation), ((double)accuracy), @"Number fails expectation."); \
+ XCTAssertTrue(0==strcmp([n objCType], @encode(double)), @"Type expectation failure. Wanted %s, got %s.", @encode(double), [n objCType]); \
+ XCTAssertEqualWithAccuracy([n doubleValue], ((double)expectation), ((double)accuracy), @"Number fails expectation."); \
} while (0)
@@ -6,11 +6,11 @@
// Copyright (c) 2014 In The Beginning... All rights reserved.
//
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#import "CPRegexpRecogniser.h"
#import "CPKeywordToken.h"
-@interface CPRegexpRecogniserTest : SenTestCase
+@interface CPRegexpRecogniserTest : XCTestCase
@end
@@ -37,17 +37,17 @@ - (void)testRecognizeRegexp
return [CPKeywordToken tokenWithKeyword:matchedString];
}];
CPKeywordToken* token = (CPKeywordToken*) [recognizer recogniseTokenInString:@"hello world" currentTokenPosition:&position];
- STAssertEqualObjects([token class], [CPKeywordToken class], @"should be keyword token");
- STAssertEqualObjects(@"hello", [token keyword], @"should match the string hello");
+ XCTAssertEqualObjects([token class], [CPKeywordToken class], @"should be keyword token");
+ XCTAssertEqualObjects(@"hello", [token keyword], @"should match the string hello");
position = 5;
token = (CPKeywordToken*) [recognizer recogniseTokenInString:@"hello world" currentTokenPosition:&position];
- STAssertNil(token, @"should not match space");
+ XCTAssertNil(token, @"should not match space");
position = 6;
token = (CPKeywordToken*) [recognizer recogniseTokenInString:@"hello world" currentTokenPosition:&position];
- STAssertEqualObjects([token class], [CPKeywordToken class], @"should be keyword token");
- STAssertEqualObjects(@"world", [token keyword], @"should match the string world");
+ XCTAssertEqualObjects([token class], [CPKeywordToken class], @"should be keyword token");
+ XCTAssertEqualObjects(@"world", [token keyword], @"should match the string world");
}
- (void)testReturnNilFromCallbackWillNotSkipContent
@@ -58,8 +58,8 @@ - (void)testReturnNilFromCallbackWillNotSkipContent
return nil;
}];
CPKeywordToken* token = (CPKeywordToken*) [recognizer recogniseTokenInString:@"hello world" currentTokenPosition:&position];
- STAssertNil(token, @"should be nil");
- STAssertTrue(position == 0, @"should not skip content if callback return nil");
+ XCTAssertNil(token, @"should be nil");
+ XCTAssertTrue(position == 0, @"should not skip content if callback return nil");
}
@end
@@ -6,8 +6,8 @@
// Copyright (c) 2012 In The Beginning... All rights reserved.
//
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
-@interface CPSTAssertionsTests : SenTestCase
+@interface CPSTAssertionsTests : XCTestCase
@end
@@ -22,19 +22,12 @@ - (id)init
if (nil != self)
{
- symbolsSet = [[NSCharacterSet characterSetWithCharactersInString:@"*[]{}().,;@|-!=<>:!"] retain];
+ symbolsSet = [NSCharacterSet characterSetWithCharactersInString:@"*[]{}().,;@|-!=<>:!"];
}
return self;
}
-- (void)dealloc
-{
- [symbolsSet release];
-
- [super dealloc];
-}
-
- (BOOL)tokeniser:(CPTokeniser *)tokeniser shouldConsumeToken:(CPToken *)token
{
NSString *name = [token name];
@@ -6,13 +6,13 @@
// Copyright (c) 2014 In The Beginning... All rights reserved.
//
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#import "CPTokeniser.h"
#import "CPKeywordRecogniser.h"
#import "CPKeywordToken.h"
#import "CPEOFToken.h"
-@interface CPWillFinishDelegateTest : SenTestCase <CPTokeniserDelegate>
+@interface CPWillFinishDelegateTest : XCTestCase <CPTokeniserDelegate>
@end
@@ -32,13 +32,13 @@ - (void)tearDown
- (void)testWillFinishCalled
{
- CPTokeniser *tokeniser = [[[CPTokeniser alloc] init] autorelease];
+ CPTokeniser *tokeniser = [[CPTokeniser alloc] init];
tokeniser.delegate = self;
[tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"{"]];
[tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"}"]];
CPTokenStream *tokenStream = [tokeniser tokenise:@"{}"];
CPTokenStream *expectedTokenStream = [CPTokenStream tokenStreamWithTokens:[NSArray arrayWithObjects:[CPKeywordToken tokenWithKeyword:@"{"], [CPKeywordToken tokenWithKeyword:@"}"], [CPKeywordToken tokenWithKeyword:@"done"], [CPEOFToken eof], nil]];
- STAssertEqualObjects(tokenStream, expectedTokenStream, @"tokeniser:WillFinish:stream not called", nil);
+ XCTAssertEqualObjects(tokenStream, expectedTokenStream, @"tokeniser:WillFinish:stream not called", nil);
}
- (BOOL)tokeniser:(CPTokeniser *)tokeniser shouldConsumeToken:(CPToken *)token
@@ -1,15 +0,0 @@
-//
-// CoreParseTests.h
-// CoreParseTests
-//
-// Created by Tom Davie on 10/02/2011.
-// Copyright 2011 In The Beginning... All rights reserved.
-//
-
-#import <SenTestingKit/SenTestingKit.h>
-
-
-@interface CoreParseTests : SenTestCase
-{}
-
-@end
Oops, something went wrong.

0 comments on commit 73f2b85

Please sign in to comment.