2016-12-25 03:59:01 +00:00
|
|
|
//
|
|
|
|
// TimeTests.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 24/12/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-12-25 03:59:01 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
|
|
|
|
#include "Storage.hpp"
|
|
|
|
|
|
|
|
@interface TimeTests : XCTestCase
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TimeTests
|
|
|
|
|
2016-12-25 04:21:19 +00:00
|
|
|
- (void)testHalf
|
2016-12-25 03:59:01 +00:00
|
|
|
{
|
|
|
|
Storage::Time half(0.5f);
|
|
|
|
XCTAssert(half == Storage::Time(1, 2), @"0.5 should be converted to 1/2");
|
|
|
|
}
|
|
|
|
|
2016-12-25 04:21:19 +00:00
|
|
|
- (void)testTwenty
|
|
|
|
{
|
|
|
|
Storage::Time twenty(20.0f);
|
|
|
|
XCTAssert(twenty == Storage::Time(20, 1), @"20.0 should be converted to 20/1");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testTooSmallFloat
|
|
|
|
{
|
|
|
|
float original = 1.0f / powf(2.0f, 25.0f);
|
|
|
|
Storage::Time time(original);
|
|
|
|
XCTAssert(time == Storage::Time(0), @"Numbers too small to be represented should be 0");
|
|
|
|
}
|
|
|
|
|
2016-12-25 04:29:37 +00:00
|
|
|
- (void)testTooBigFloat
|
|
|
|
{
|
|
|
|
float original = powf(2.0f, 48.0f);
|
|
|
|
Storage::Time time(original);
|
|
|
|
XCTAssert(time == Storage::Time::max(), @"Numbers too big to be represented should saturate");
|
|
|
|
}
|
|
|
|
|
2016-12-25 03:59:01 +00:00
|
|
|
@end
|