This repository has been archived by the owner on May 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
MaxTest.swift
39 lines (31 loc) · 1.5 KB
/
MaxTest.swift
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
//
// MaxTest.swift
// Honour
//
// Created by Jean Pimentel on 7/27/15.
// Copyright (c) 2015 Honour. All rights reserved.
//
import XCTest
import Honour
class MaxTest: XCTestCase {
func testValidMax() {
XCTAssertTrue(Max(max: 500).validate(400))
XCTAssertTrue(Max(max: 500).validate(500))
XCTAssertTrue(Max(max: 0.5, inclusive: false).validate(0.4999))
let sameDate = NSDate()
XCTAssertTrue(Max(max: sameDate).validate(sameDate))
XCTAssertTrue(Max(max: NSDate()).validate(NSDate(timeIntervalSinceNow: -86400)))
XCTAssertTrue(Max(max: NSDate()).validate(NSDate(timeIntervalSinceNow: -1)))
XCTAssertTrue(Max(max: NSDate(timeIntervalSince1970: 1440636124), inclusive: false).validate(NSDate(timeIntervalSince1970: 1440636123)))
}
func testInvalidMax() {
XCTAssertFalse(Max(max: 500).validate(501))
XCTAssertFalse(Max(max: 500, inclusive: false).validate(500))
XCTAssertFalse(Max(max: 500, inclusive: false).validate(501))
XCTAssertFalse(Max(max: 1, inclusive: false).validate(1.001))
XCTAssertFalse(Max(max: 0.5, inclusive: false).validate(0.500))
XCTAssertFalse(Max(max: NSDate()).validate(NSDate(timeIntervalSinceNow: +86400)))
XCTAssertFalse(Max(max: NSDate()).validate(NSDate(timeIntervalSinceNow: +1)))
XCTAssertFalse(Max(max: NSDate(timeIntervalSince1970: 1440636123), inclusive: false).validate(NSDate(timeIntervalSince1970: 1440636123)))
}
}