diff --git a/SecondsFormatterTests/SecondsFormatterTests.m b/SecondsFormatterTests/SecondsFormatterTests.m index 63fe1330b..9253458dd 100644 --- a/SecondsFormatterTests/SecondsFormatterTests.m +++ b/SecondsFormatterTests/SecondsFormatterTests.m @@ -32,6 +32,36 @@ // Use XCTAssert and related functions to verify your tests produce the correct results. } +- (void)testPositive +{ + NSDictionary *testsDict = + @{ + // key: test name, value: test string + //@"Example": @"0:00", + @"One Second": @"0:01", + @"One Minute": @"1:00", + @"One Hour": @"1:00:00", + @"One Day": @"1:00:00:00", + @"One of Each": @"1:01:01:01", + }; + +#define TEST_INFO @"Test name: %@, Source string: %@", testName, string + + NSFormatter *secondsFormatter = [[SecondsFormatter alloc] init]; + + [testsDict enumerateKeysAndObjectsUsingBlock: + ^(NSString *testName, NSString *string, BOOL * _Nonnull stop) { + NSNumber *value; + BOOL result = + [secondsFormatter getObjectValue:&value + forString:string + errorDescription:NULL]; + XCTAssertTrue(result, TEST_INFO); + NSString *timeString = [secondsFormatter stringForObjectValue:value]; + XCTAssertEqualObjects(string, timeString, TEST_INFO); + }]; +} + #if 0 - (void)testPerformanceExample {