mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 09:18:29 +00:00
Add assertion and tests for non unique diffIdentifiers
Summary: Issue fixed: #814 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes https://github.com/Instagram/IGListKit/pull/821 Differential Revision: D5301480 Pulled By: rnystrom fbshipit-source-id: 3a1989aae8de5d03aa803d51b88c65eed999c4bb
This commit is contained in:
parent
26bb86aa0c
commit
8073736772
4 changed files with 10 additions and 2 deletions
|
|
@ -5,7 +5,7 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
|
|||
3.1.0 (**upcoming release**)
|
||||
-----
|
||||
|
||||
3.0.0
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit/milestone/3).
|
||||
|
|
|
|||
|
|
@ -494,8 +494,11 @@
|
|||
IGParameterAssert(dataSource != nil);
|
||||
|
||||
#if DEBUG
|
||||
NSCountedSet *identifiersSet = [NSCountedSet new];
|
||||
for (id object in objects) {
|
||||
[identifiersSet addObject:[object diffIdentifier]];
|
||||
IGAssert([object isEqualToDiffableObject:object], @"Object instance %@ not equal to itself. This will break infra map tables.", object);
|
||||
IGAssert([identifiersSet countForObject:[object diffIdentifier]] <= 1, @"Diff identifier %@ for object %@ occurs more than once. Identifiers must be unique!", [object diffIdentifier], object);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1248,4 +1248,9 @@
|
|||
XCTAssertEqual(collectionView1.dataSource, adapter2);
|
||||
}
|
||||
|
||||
- (void)test_whenPassingNonUniqueIdentifiers_adapterShouldAssert {
|
||||
self.dataSource.objects = @[@0, @1, @2, @0];
|
||||
XCTAssertThrows([self.adapter reloadDataWithCompletion:nil]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
adapter3.collectionView = collectionView;
|
||||
|
||||
NSArray *descriptions = [IGListDebugger adapterDescriptions];
|
||||
XCTAssertEqual(descriptions.count, 3);
|
||||
XCTAssertEqual(descriptions.count, 4);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in a new issue