Skip to content

Commit

Permalink
Remove unused APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjernst committed Apr 17, 2015
1 parent 47e7adb commit 17ddec7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 109 deletions.
14 changes: 0 additions & 14 deletions ComponentKit/DataSources/Common/CKComponentDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ typedef void(^CKComponentDataSourceEnumerator)(CKComponentDataSourceOutputItem *

- (void)enumerateObjectsInSectionAtIndex:(NSInteger)section usingBlock:(CKComponentDataSourceEnumerator)block;

typedef BOOL(^CKComponentDataSourcePredicate)(CKComponentDataSourceOutputItem *, NSIndexPath *, BOOL *);

/**
@predicate Returning YES from the predicate will halt searching. Passing a nil predicate will return a {nil, nil} pair.
@returns The object passing `predicate` and its corresponding index path. Nil in both fields indicates nothing passed.
This will always return both fields as nil or non-nil.
*/
- (std::pair<CKComponentDataSourceOutputItem *, NSIndexPath *>)firstObjectPassingTest:(CKComponentDataSourcePredicate)predicate;

/**
This is O(N).
*/
- (std::pair<CKComponentDataSourceOutputItem *, NSIndexPath *>)objectForUUID:(NSString *)UUID;

/**
@return YES if the datasource has changesets currently enqueued.
*/
Expand Down
13 changes: 0 additions & 13 deletions ComponentKit/DataSources/Common/CKComponentDataSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@ - (void)enumerateObjectsInSectionAtIndex:(NSInteger)section usingBlock:(CKCompon
}
}

- (std::pair<CKComponentDataSourceOutputItem *, NSIndexPath *>)firstObjectPassingTest:(CKComponentDataSourcePredicate)predicate
{
return [_outputArrayController firstObjectPassingTest:predicate];
}

- (std::pair<CKComponentDataSourceOutputItem *, NSIndexPath *>)objectForUUID:(NSString *)UUID
{
return [self firstObjectPassingTest:
^BOOL(CKComponentDataSourceOutputItem *object, NSIndexPath *indexPath, BOOL *stop) {
return [[object UUID] isEqual:UUID];
}];
}

- (void)enqueueReload
{
__block CKArrayControllerInputItems items;
Expand Down
29 changes: 0 additions & 29 deletions ComponentKitTests/CKComponentDataSourceTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1059,35 +1059,6 @@ - (void)configureWithMultipleSectionsAndItems
[_delegate reset];
}

- (void)testObjectForUUIDWithNilUUIDReturnsNil
{
[self configureWithMultipleSectionsAndItems];

auto pair = [_dataSource objectForUUID:nil];
XCTAssertNil(pair.first);
XCTAssertNil(pair.second);
}

- (void)testObjectForUUIDWithNotFoundUUIDReturnsNil
{
[self configureWithMultipleSectionsAndItems];

auto pair = [_dataSource objectForUUID:@"123456789"];
XCTAssertNil(pair.first);
XCTAssertNil(pair.second);
}

- (void)testObjectForUUIDReturnsObjectWhenFound
{
[self configureWithMultipleSectionsAndItems];

CKComponentDataSourceOutputItem *item = [_dataSource objectAtIndexPath:IndexPath(1, 0).toNSIndexPath()];
auto pair = [_dataSource objectForUUID:[item UUID]];

XCTAssertEqualObjects([pair.first model], @"Batman");
XCTAssertEqualObjects(pair.second, IndexPath(1, 0).toNSIndexPath());
}

- (void)testIsComputingChanges
{
[self configureWithMultipleSectionsAndItems];
Expand Down
53 changes: 0 additions & 53 deletions ComponentKitTests/CKSectionedArrayControllerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -566,57 +566,4 @@ - (void)testFullEnumerationStop
XCTAssertTrue(enumerated == expected, @"");
}

- (void)testFirstObjectPassingTestWithNilPredicate
{
[_controller applyChangeset:_multipleSectionInput()];
auto pair = [_controller firstObjectPassingTest:nil];
XCTAssertNil(pair.first, @"");
XCTAssertNil(pair.second, @"");
}

- (void)testFirstObjectPassingTestWithNonNilPredicate
{
[_controller applyChangeset:_multipleSectionInput()];
auto pair = [_controller firstObjectPassingTest:^BOOL(id<NSObject> object, NSIndexPath *indexPath, BOOL *stop) {
return [object isEqual:@1];
}];
XCTAssertEqualObjects(pair.first, @1, @"");
XCTAssertEqualObjects(pair.second, [NSIndexPath indexPathForItem:1 inSection:0], @"");
}

- (void)testFirstObjectPassingTestStop
{
[_controller applyChangeset:_multipleSectionInput()];

NSMutableArray *enumerated = [[NSMutableArray alloc] init];
auto pair = [_controller firstObjectPassingTest:^BOOL(id<NSObject> object, NSIndexPath *indexPath, BOOL *stop) {
*stop = [indexPath isEqual:[NSIndexPath indexPathForItem:0 inSection:1]];
[enumerated addObject:object];
return NO;
}];

NSArray *expected = @[@0, @1, @2];
XCTAssertEqualObjects(enumerated, expected, @"");
}

- (void)testFirstObjectPassingTestWithMultipleMatchesReturnsFirst
{
[_controller applyChangeset:_multipleSectionInput()];
auto pair = [_controller firstObjectPassingTest:^BOOL(id<NSObject> object, NSIndexPath *indexPath, BOOL *stop) {
return YES;
}];
XCTAssertEqualObjects(pair.first, @0, @"");
XCTAssertEqualObjects(pair.second, [NSIndexPath indexPathForItem:0 inSection:0], @"");
}

- (void)testFirstObjectPassingTestWithNoMatchesReturnsNil
{
[_controller applyChangeset:_multipleSectionInput()];
auto pair = [_controller firstObjectPassingTest:^BOOL(id<NSObject> object, NSIndexPath *indexPath, BOOL *stop) {
return NO;
}];
XCTAssertNil(pair.first, @"");
XCTAssertNil(pair.second, @"");
}

@end

0 comments on commit 17ddec7

Please sign in to comment.