Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
Migrate from OCUnit to XCTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Oct 14, 2014
1 parent ce34e5e commit 13f8cb2
Show file tree
Hide file tree
Showing 42 changed files with 1,088 additions and 1,095 deletions.
4 changes: 2 additions & 2 deletions Todo-txt-unit-tests/AndFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface AndFilterTest : SenTestCase
@interface AndFilterTest : XCTestCase

@end
8 changes: 4 additions & 4 deletions Todo-txt-unit-tests/AndFilterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,31 @@ @implementation AndFilterTest
- (void)testNoFilters
{
AndFilter *andFilter = [[[AndFilter alloc] init] autorelease];
STAssertTrue([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) abc 123"] autorelease]], @"apply was not true");
XCTAssertTrue([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) abc 123"] autorelease]], @"apply was not true");
}

- (void)testMultipleFilters_matchesBoth
{
AndFilter *andFilter = [[[AndFilter alloc] init] autorelease];
[andFilter addFilter:[[ByPriorityFilter alloc] initWithPriorities:[[NSArray arrayWithObject:[Priority byName:PriorityA]] autorelease]]];
[andFilter addFilter:[[[ByTextFilter alloc] initWithText:@"abc" caseSensitive:false] autorelease]];
STAssertTrue([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) abc 123"] autorelease]], @"apply was not true");
XCTAssertTrue([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) abc 123"] autorelease]], @"apply was not true");
}

- (void)testMultipleFilters_matchesOnlyOne
{
AndFilter *andFilter = [[[AndFilter alloc] init] autorelease];
[andFilter addFilter:[[ByPriorityFilter alloc] initWithPriorities:[[NSArray arrayWithObject:[Priority byName:PriorityA]] autorelease]]];
[andFilter addFilter:[[[ByTextFilter alloc] initWithText:@"abc" caseSensitive:false] autorelease]];
STAssertFalse([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not false");
}

- (void)testMultipleFilters_matchesNone
{
AndFilter *andFilter = [[[AndFilter alloc] init] autorelease];
[andFilter addFilter:[[ByPriorityFilter alloc] initWithPriorities:[[NSArray arrayWithObject:[Priority byName:PriorityA]] autorelease]]];
[andFilter addFilter:[[[ByTextFilter alloc] initWithText:@"abc" caseSensitive:false] autorelease]];
STAssertFalse([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(B) hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([andFilter apply:[[[Task alloc] initWithId:1 withRawText:@"(B) hello world"] autorelease]], @"apply was not false");
}

@end
4 changes: 2 additions & 2 deletions Todo-txt-unit-tests/ByContextFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface ByContextFilterTest : SenTestCase
@interface ByContextFilterTest : XCTestCase

@end
32 changes: 16 additions & 16 deletions Todo-txt-unit-tests/ByContextFilterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,72 +51,72 @@ @implementation ByContextFilterTest
- (void)testConstructor_nilContexts
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:nil];
STAssertNil(filter.contexts, @"contexts shoud be nil");
STAssertEquals(0U, filter.contexts.count, @"contexts count should be zero");
XCTAssertNil(filter.contexts, @"contexts shoud be nil");
XCTAssertEqual(0U, filter.contexts.count, @"contexts count should be zero");
}

- (void)testConstructor_valid
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertNotNil(filter.contexts, @"contexts shoud not be nil");
STAssertEquals(3U, filter.contexts.count, @"contexts count should be three");
STAssertEqualObjects(@"abc", [filter.contexts objectAtIndex:0], @"first context should be \"abc\"");
STAssertEqualObjects(@"123", [filter.contexts objectAtIndex:1], @"second context should be \"123\"");
STAssertEqualObjects(@"hello", [filter.contexts objectAtIndex:2], @"third context should be \"hello\"");
XCTAssertNotNil(filter.contexts, @"contexts shoud not be nil");
XCTAssertEqual(3U, filter.contexts.count, @"contexts count should be three");
XCTAssertEqualObjects(@"abc", [filter.contexts objectAtIndex:0], @"first context should be \"abc\"");
XCTAssertEqualObjects(@"123", [filter.contexts objectAtIndex:1], @"second context should be \"123\"");
XCTAssertEqualObjects(@"hello", [filter.contexts objectAtIndex:2], @"third context should be \"hello\"");
}

- (void)testFilter_noFilterContexts_noTaskContexts
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterContext_noTaskContexts
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObject:@"abc"]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
}

- (void)testFilter_noFilterContext_oneTaskContexts
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @abc"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @abc"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterContext_sameTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObject:@"abc"]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @abc"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @abc"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterContext_differentTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObject:@"abc"]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123"] autorelease]], @"apply was not false");
}

- (void)testFilter_multipleFilterContext_oneSameTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterContext_multipleTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123 @goodbye"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123 @goodbye"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterContext_multipleSameTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123 @hello"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @123 @hello"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterContext_multipleDifferentTaskContext
{
ByContextFilter *filter = [[ByContextFilter alloc] initWithContexts:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @xyz @goodbye"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world @xyz @goodbye"] autorelease]], @"apply was not false");
}

@end
4 changes: 2 additions & 2 deletions Todo-txt-unit-tests/ByPriorityFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface ByPriorityFilterTest : SenTestCase
@interface ByPriorityFilterTest : XCTestCase

@end
26 changes: 13 additions & 13 deletions Todo-txt-unit-tests/ByPriorityFilterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,59 +51,59 @@ @implementation ByPriorityFilterTest
- (void)testConstructor_nilPriorities
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:nil];
STAssertNil(filter.priorities, @"priorities shoud be nil");
STAssertEquals(0U, filter.priorities.count, @"priorities count should be zero");
XCTAssertNil(filter.priorities, @"priorities shoud be nil");
XCTAssertEqual(0U, filter.priorities.count, @"priorities count should be zero");
}

- (void)testConstructor_valid
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObjects:[Priority byName:PriorityA], [Priority byName:PriorityB], nil]];
STAssertNotNil(filter.priorities, @"priorities shoud not be nil");
STAssertEquals(2U, filter.priorities.count, @"priorities count should be three");
STAssertEquals([Priority byName:PriorityA], [filter.priorities objectAtIndex:0], @"first priority should be \"A\"");
STAssertEquals([Priority byName:PriorityB], [filter.priorities objectAtIndex:1], @"second priority should be \"B\"");
XCTAssertNotNil(filter.priorities, @"priorities shoud not be nil");
XCTAssertEqual(2U, filter.priorities.count, @"priorities count should be three");
XCTAssertEqual([Priority byName:PriorityA], [filter.priorities objectAtIndex:0], @"first priority should be \"A\"");
XCTAssertEqual([Priority byName:PriorityB], [filter.priorities objectAtIndex:1], @"second priority should be \"B\"");
}

- (void)testFilter_noFilterPriorities_noTaskPriorities
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterPriority_noTaskPriorities
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObject:[Priority byName:PriorityA]]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
}

- (void)testFilter_noFilterPriority_oneTaskPriorities
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterPriority_sameTaskPriority
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObject:[Priority byName:PriorityA]]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterPriority_differentTaskPriority
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObject:[Priority byName:PriorityA]]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(B) hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(B) hello world"] autorelease]], @"apply was not false");
}

- (void)testFilter_multipleFilterPriority_oneSameTaskPriority
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObjects:[Priority byName:PriorityA], [Priority byName:PriorityB], nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(A) hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterPriority_oneDifferentTaskPriority
{
ByPriorityFilter *filter = [[ByPriorityFilter alloc] initWithPriorities:[NSArray arrayWithObjects:[Priority byName:PriorityA], [Priority byName:PriorityB], nil]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(C) hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"(C) hello world"] autorelease]], @"apply was not false");
}

@end
4 changes: 2 additions & 2 deletions Todo-txt-unit-tests/ByProjectFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface ByProjectFilterTest : SenTestCase
@interface ByProjectFilterTest : XCTestCase

@end
32 changes: 16 additions & 16 deletions Todo-txt-unit-tests/ByProjectFilterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,72 +51,72 @@ @implementation ByProjectFilterTest
- (void)testConstructor_nilProjects
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:nil];
STAssertNil(filter.projects, @"projects shoud be nil");
STAssertEquals(0U, filter.projects.count, @"projects count should be zero");
XCTAssertNil(filter.projects, @"projects shoud be nil");
XCTAssertEqual(0U, filter.projects.count, @"projects count should be zero");
}

- (void)testConstructor_valid
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertNotNil(filter.projects, @"projects shoud not be nil");
STAssertEquals(3U, filter.projects.count, @"projects count should be three");
STAssertEqualObjects(@"abc", [filter.projects objectAtIndex:0], @"first project should be \"abc\"");
STAssertEqualObjects(@"123", [filter.projects objectAtIndex:1], @"second project should be \"123\"");
STAssertEqualObjects(@"hello", [filter.projects objectAtIndex:2], @"third project should be \"hello\"");
XCTAssertNotNil(filter.projects, @"projects shoud not be nil");
XCTAssertEqual(3U, filter.projects.count, @"projects count should be three");
XCTAssertEqualObjects(@"abc", [filter.projects objectAtIndex:0], @"first project should be \"abc\"");
XCTAssertEqualObjects(@"123", [filter.projects objectAtIndex:1], @"second project should be \"123\"");
XCTAssertEqualObjects(@"hello", [filter.projects objectAtIndex:2], @"third project should be \"hello\"");
}

- (void)testFilter_noFilterProjects_noTaskProjects
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterProject_noTaskProjects
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObject:@"abc"]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world"] autorelease]], @"apply was not false");
}

- (void)testFilter_noFilterProject_oneTaskProjects
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:nil];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +abc"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +abc"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterProject_sameTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObject:@"abc"]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +abc"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +abc"] autorelease]], @"apply was not true");
}

- (void)testFilter_oneFilterProject_differentTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObject:@"abc"]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123"] autorelease]], @"apply was not false");
}

- (void)testFilter_multipleFilterProject_oneSameTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterProject_multipleTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123 +goodbye"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123 +goodbye"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterProject_multipleSameTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123 +hello"] autorelease]], @"apply was not true");
XCTAssertTrue([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +123 +hello"] autorelease]], @"apply was not true");
}

- (void)testFilter_multipleFilterProject_multipleDifferentTaskProject
{
ByProjectFilter *filter = [[ByProjectFilter alloc] initWithProjects:[NSArray arrayWithObjects:@"abc", @"123", @"hello", nil]];
STAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +xyz +goodbye"] autorelease]], @"apply was not false");
XCTAssertFalse([filter apply:[[[Task alloc] initWithId:1 withRawText:@"hello world +xyz +goodbye"] autorelease]], @"apply was not false");
}

@end
4 changes: 2 additions & 2 deletions Todo-txt-unit-tests/ByTextFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface ByTextFilterTest : SenTestCase
@interface ByTextFilterTest : XCTestCase

@end
Loading

0 comments on commit 13f8cb2

Please sign in to comment.