Skip to content

Commit

Permalink
Merge pull request #84 from 8W9aG/add-timer-test
Browse files Browse the repository at this point in the history
Add timer tests
  • Loading branch information
8W9aG committed Feb 3, 2016
2 parents f2b6fe5 + 6864d46 commit 2ca6289
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions SPTDataLoaderTests/SPTDataLoaderExponentialTimerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,23 @@ - (void)testReset
XCTAssertEqualWithAccuracy(self.timer.timeInterval, 1.0, DBL_EPSILON);
}

- (void)testInitialTimeOfZeroResultsInZeroAlways
{
self.timer = [SPTDataLoaderExponentialTimer exponentialTimerWithInitialTime:0.0 maxTime:10.0 jitter:0.0];
NSTimeInterval currentTimerInterval = 0.0;
for (int i = 0; i < 10; ++i) {
currentTimerInterval = [self.timer timeIntervalAndCalculateNext];
}
XCTAssertEqualWithAccuracy(currentTimerInterval, 0.0, DBL_EPSILON);
}

- (void)testMaxTimeReached
{
NSTimeInterval currentTimerInterval = 0.0;
for (int i = 0; i < 100; ++i) {
currentTimerInterval = [self.timer timeIntervalAndCalculateNext];
}
XCTAssertLessThanOrEqual(currentTimerInterval, 10.0);
}

@end

0 comments on commit 2ca6289

Please sign in to comment.