Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UITableView+Reorder/UITableView+Reorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ - (void) verifyConfiguration {
NSIndexPath *indexPathForH0;
CGFloat h1;
NSIndexPath *indexPathForH1;
NSInteger sectionCount = [self.dataSource numberOfSectionsInTableView: self];
NSInteger sectionCount = [self.dataSource respondsToSelector:@selector(numberOfSectionsInTableView:)] ? [self.dataSource numberOfSectionsInTableView: self] : 1;
for( NSInteger section = 0; section < sectionCount; ++section ) {
NSInteger rowCount = [self.dataSource tableView: self numberOfRowsInSection: section];
for( NSInteger row = 0; row < rowCount; ++row ) {
Expand Down
52 changes: 26 additions & 26 deletions UITableView+ReorderTests/UITableView_ReorderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,65 +53,65 @@ - (void) test_NSIndexPathIsAboveRowAtIndexPath {
NSIndexPath *rowB;

rowA = [NSIndexPath indexPathForRow: 0 inSection: 0];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: nil], @"Row %d,%d cannot be above nil", rowA.section, rowA.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: nil], @"Row %ld,%ld cannot be above nil",(long)rowA.section, (long)rowA.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 0];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should not be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should not be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 1 inSection: 0];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 1];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 1 inSection: 1];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );

rowA = [NSIndexPath indexPathForRow: 2 inSection: 3];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: nil], @"Row %d,%d cannot be above nil", rowA.section, rowA.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: nil], @"Row %ld,%ld cannot be above nil", (long)rowA.section, (long)rowA.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 0];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should not be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should not be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 1 inSection: 0];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should not be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should not be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 1];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should not be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should not be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 2 inSection: 3];
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should not be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should not be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 3 inSection: 3];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 4];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 3 inSection: 4];
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %d,%d should be above %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isAboveRowAtIndexPath: rowB], @"Row %ld,%ld should be above %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
}

- (void) test_NSIndexPathIsBelowRowAtIndexPath {
NSIndexPath *rowA;
NSIndexPath *rowB;

rowA = [NSIndexPath indexPathForRow: 1 inSection: 1];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: nil], @"Row %d,%d cannot be below nil", rowA.section, rowA.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: nil], @"Row %ld,%ld cannot be below nil", (long)rowA.section, (long)rowA.row );
rowB = [NSIndexPath indexPathForRow: 1 inSection: 1];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should not be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should not be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 1 inSection: 0];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 1];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 0];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );

rowA = [NSIndexPath indexPathForRow: 2 inSection: 3];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: nil], @"Row %d,%d cannot be below nil", rowA.section, rowA.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: nil], @"Row %ld,%ld cannot be below nil", (long)rowA.section, (long)rowA.row );
rowB = [NSIndexPath indexPathForRow: 2 inSection: 3];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should not be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should not be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 3 inSection: 3];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should not be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should not be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 4];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should not be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should not be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 2 inSection: 4];
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should not be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertFalse( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should not be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 3 inSection: 2];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 3];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
rowB = [NSIndexPath indexPathForRow: 0 inSection: 0];
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %d,%d should be below %d,%d", rowA.section, rowA.row, rowB.section, rowB.row );
XCTAssertTrue( [rowA isBelowRowAtIndexPath: rowB], @"Row %ld,%ld should be below %ld,%ld", (long)rowA.section, (long)rowA.row, (long)rowB.section, (long)rowB.row );
}
//------------------------------------------------------------------------------

Expand Down