-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathGigasecondTest.m
66 lines (54 loc) · 2.46 KB
/
GigasecondTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#import <XCTest/XCTest.h>
#if __has_include("GigasecondExample.h")
# import "GigasecondExample.h"
# else
# import "Gigasecond.h"
#endif
@interface GigasecondTest : XCTestCase
@end
@implementation GigasecondTest {
NSDateFormatter *_dateFormatter;
}
- (void)setUp {
[super setUp];
_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[_dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
}
- (void)test1 {
NSDate *startDate = [_dateFormatter dateFromString:@"2011-04-25T00:00:00"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"2043-01-01T01:46:40"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
- (void)test2 {
NSDate *startDate = [_dateFormatter dateFromString:@"1977-06-13T00:00:00"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"2009-02-19T01:46:40"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
- (void)test3 {
NSDate *startDate = [_dateFormatter dateFromString:@"1959-07-19T00:00:00"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"1991-03-27T01:46:40"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
- (void)test24HourTime {
NSDate *startDate = [_dateFormatter dateFromString:@"2015-01-24T22:00:00"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"2046-10-02T23:46:40"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
- (void)testTimeWithSeconds {
NSDate *startDate = [_dateFormatter dateFromString:@"1959-07-19T23:59:59"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"1991-03-28T01:46:39"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
- (void)testFullTimeWithDayRollOver {
NSDate *startDate = [_dateFormatter dateFromString:@"2015-01-24T23:59:59"];
Gigasecond *gigasecond = [[Gigasecond alloc] initWithStartDate:startDate];
NSDate *expectedDate = [_dateFormatter dateFromString:@"2046-10-03T01:46:39"];
XCTAssertEqualObjects(expectedDate, [gigasecond gigasecondDate]);
}
@end