Skip to content

Commit

Permalink
Resolved invalid use of nullable values in tests
Browse files Browse the repository at this point in the history
Added checks for `nil` before using values, then cast the values to `__nonnull` pointers.
  • Loading branch information
dlkinney authored and nolanw committed Nov 25, 2015
1 parent 911d6c2 commit b7d71c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Tests/HTMLSelectorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ - (void)testNthParsing
NSArray *nodes = [self.testDoc nodesMatchingSelector:(selectorString)]; \
NSMutableArray *IDs = [NSMutableArray new]; \
for (HTMLElement *node in nodes) { \
[IDs addObject:(node[@"id"] ?: node.tagName)]; \
id object = node[@"id"] ?: node.tagName; \
if (object) { \
[IDs addObject:(id __nonnull)object]; \
} \
} \
XCTAssertEqualObjects(IDs, expectedIDs); \
} while(0)
Expand Down
5 changes: 3 additions & 2 deletions Tests/HTMLTreeConstructionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ BOOL TreesAreTestEquivalent(id aThing, id bThing)
if (![bThing isKindOfClass:[HTMLDocumentType class]]) return NO;
HTMLDocumentType *a = aThing, *b = bThing;
return (((a.name == nil && b.name == nil) || [a.name isEqualToString:b.name]) &&
[a.publicIdentifier isEqualToString:b.publicIdentifier] &&
[a.systemIdentifier isEqualToString:b.systemIdentifier]);
b.publicIdentifier != nil && b.systemIdentifier != nil &&
[a.publicIdentifier isEqualToString:(NSString * __nonnull)b.publicIdentifier] &&
[a.systemIdentifier isEqualToString:(NSString * __nonnull)b.systemIdentifier]);
} else if (arrayLike(aThing)) {
if (!arrayLike(bThing)) return NO;
NSArray *a = aThing, *b = bThing;
Expand Down

0 comments on commit b7d71c9

Please sign in to comment.