From 9e4007dcba0aded08f0c094d3a2c9228b9c679db Mon Sep 17 00:00:00 2001 From: iska Date: Sun, 29 Nov 2015 00:42:19 +0100 Subject: [PATCH] Use nullability annotations for HTML Ordered Dictionary --- HTMLKit/HTMLOrderedDictionary.h | 20 ++++++++++++-------- HTMLKitTests/HTMLKitOrderedDictionaryTests.m | 10 ---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/HTMLKit/HTMLOrderedDictionary.h b/HTMLKit/HTMLOrderedDictionary.h index aad6baf..088b02a 100644 --- a/HTMLKit/HTMLOrderedDictionary.h +++ b/HTMLKit/HTMLOrderedDictionary.h @@ -8,18 +8,22 @@ #import -@interface HTMLOrderedDictionary : NSMutableDictionary +NS_ASSUME_NONNULL_BEGIN -- (id)objectAtIndex:(NSUInteger)index; -- (void)setObject:(id)anObject forKey:(id)aKey atIndex:(NSUInteger)index; +@interface HTMLOrderedDictionary : NSMutableDictionary + +- (ObjectType)objectAtIndex:(NSUInteger)index; +- (void)setObject:(ObjectType)anObject forKey:(KeyType)aKey atIndex:(NSUInteger)index; - (void)removeObjectAtIndex:(NSUInteger)index; -- (void)replaceKeyValueAtIndex:(NSUInteger)index withObject:(id)anObject andKey:(id)aKey; -- (void)replaceKey:(id)aKey withKey:(id)newKey; -- (NSUInteger)indexOfKey:(id)aKey; +- (void)replaceKeyValueAtIndex:(NSUInteger)index withObject:(ObjectType)anObject andKey:(KeyType)aKey; +- (void)replaceKey:(KeyType)aKey withKey:(KeyType)newKey; +- (NSUInteger)indexOfKey:(KeyType)aKey; -- (id)objectAtIndexedSubscript:(NSUInteger)index; -- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index; +- (ObjectType)objectAtIndexedSubscript:(NSUInteger)index; +- (void)setObject:(ObjectType)obj atIndexedSubscript:(NSUInteger)index; - (NSEnumerator *)reverseKeyEnumerator; @end + +NS_ASSUME_NONNULL_END diff --git a/HTMLKitTests/HTMLKitOrderedDictionaryTests.m b/HTMLKitTests/HTMLKitOrderedDictionaryTests.m index c9bf8c1..d58c6cf 100644 --- a/HTMLKitTests/HTMLKitOrderedDictionaryTests.m +++ b/HTMLKitTests/HTMLKitOrderedDictionaryTests.m @@ -38,9 +38,6 @@ [_dictionary setObject:@"3" forKey:@"C"]; expected = @[@"A", @"B", @"C"]; XCTAssertEqualObjects(_dictionary.keyEnumerator.allObjects, expected); - - XCTAssertThrows([_dictionary setObject:nil forKey:@"Key"]); - XCTAssertThrows([_dictionary setObject:@"Object" forKey:nil]); } - (void)testIndexOfKey @@ -51,7 +48,6 @@ XCTAssertEqual([_dictionary indexOfKey:@"A"], 0); XCTAssertEqual([_dictionary indexOfKey:@"B"], 1); XCTAssertEqual([_dictionary indexOfKey:@"C"], 2); - XCTAssertEqual([_dictionary indexOfKey:nil], NSNotFound); } - (void)testObjectAtIndex @@ -64,8 +60,6 @@ [_dictionary setObject:@"3" forKey:@"C" atIndex:1]; XCTAssertEqualObjects([_dictionary objectAtIndex:1], @"3"); - XCTAssertThrows([_dictionary setObject:nil forKey:@"Key" atIndex:0]); - XCTAssertThrows([_dictionary setObject:@"Object" forKey:nil atIndex:0]); XCTAssertThrows([_dictionary setObject:@"Object" forKey:@"Key" atIndex:100]); } @@ -120,8 +114,6 @@ XCTAssertEqualObjects(_dictionary[2], @"5"); XCTAssertEqualObjects(_dictionary[@"A"], @"5"); - XCTAssertThrows([_dictionary setObject:nil forKey:@"Key" atIndex:0]); - XCTAssertThrows([_dictionary setObject:@"Object" forKey:nil atIndex:0]); XCTAssertThrows([_dictionary setObject:@"Object" forKey:@"Key" atIndex:100]); } @@ -158,8 +150,6 @@ XCTAssertEqualObjects(_dictionary[0], @"5"); XCTAssertEqualObjects(_dictionary[@"E"], @"5"); - XCTAssertThrows([_dictionary replaceKeyValueAtIndex:1 withObject:nil andKey:@"Key"]); - XCTAssertThrows([_dictionary replaceKeyValueAtIndex:1 withObject:@"Object" andKey:nil]); XCTAssertThrows([_dictionary replaceKeyValueAtIndex:100 withObject:@"Object" andKey:@"Key"]); }