From 5c7a0318b56bfc189c6676bc54e3b82020772106 Mon Sep 17 00:00:00 2001 From: Zhisheng Huang Date: Tue, 3 Apr 2018 17:04:12 -0700 Subject: [PATCH] Remove XCTAssertThrow in IGListAdapterTests Summary: = OSS: = It's not a good testing strategy to check against the assert, it should be checking the real expected output for a function. It limits our usage that we have to use XCTAssertThrow if there is an assertion throws. The problem is that `IGAssert` uses the `NSCAssert` which would throw an `NSInternalInconsistentException` which affects all the code path. Another follow up is to investigate how to make IGAssert not crashable. --- Reviewed By: rnystrom Differential Revision: D7481905 fbshipit-source-id: 24af37a6e1aa389317474614cdd214c9df537291 --- Tests/IGListAdapterTests.m | 41 -------------------------------------- 1 file changed, 41 deletions(-) diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index 3c54af1d..e1364c8b 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -1337,42 +1337,6 @@ XCTAssertEqual(size.height, 0.0); } -- (void)test_whenSectionControllerReturnsNANHeight_thatAssertionFires { - self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new]; - self.dataSource.objects = @[@1]; - [self.adapter reloadDataWithCompletion:nil]; - - IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]]; - section.size = CGSizeMake(NAN, 1); - - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; - XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]); -} - -- (void)test_whenSectionControllerReturnsNANWidth_thatAssertionFires { - self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new]; - self.dataSource.objects = @[@1]; - [self.adapter reloadDataWithCompletion:nil]; - - IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]]; - section.size = CGSizeMake(1, NAN); - - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; - XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]); -} - -- (void)test_whenSectionControllerReturnsNANWidthNANHeight_thatAssertionFires { - self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new]; - self.dataSource.objects = @[@1]; - [self.adapter reloadDataWithCompletion:nil]; - - IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]]; - section.size = CGSizeMake(NAN, NAN); - - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; - XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]); -} - - (void)test_whenSupplementarySourceReturnsNegativeSize_thatAdapterReturnsZero { self.dataSource.objects = @[@1]; [self.adapter reloadDataWithCompletion:nil]; @@ -1573,11 +1537,6 @@ XCTAssertEqual(collectionView1.dataSource, adapter2); } -- (void)test_whenPassingNonUniqueIdentifiers_adapterReloadShouldThrow { - self.dataSource.objects = @[@0, @1, @2, @0]; - XCTAssertThrows([self.adapter reloadDataWithCompletion:nil]); -} - - (void)test_whenPrefetchingEnabled_thatSetterDisables { UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]]; collectionView.prefetchingEnabled = YES;