forked from Brightify/Cuckoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefaultValueRegistryTest.swift
98 lines (80 loc) · 3.38 KB
/
DefaultValueRegistryTest.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// DefaultValueRegistryTest.swift
// Cuckoo
//
// Created by Filip Dolnik on 21.09.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import XCTest
import Cuckoo
class DefaultValueRegistryTest: XCTestCase {
override func setUp() {
super.setUp()
DefaultValueRegistry.reset()
}
override func tearDown() {
super.tearDown()
DefaultValueRegistry.reset()
}
func testReset() {
XCTAssertEqual(0, DefaultValueRegistry.defaultValue(for: Int.self))
DefaultValueRegistry.register(value: 10, forType: Int.self)
DefaultValueRegistry.reset()
XCTAssertEqual(0, DefaultValueRegistry.defaultValue(for: Int.self))
}
func testRegisterValue() {
let value = 10
DefaultValueRegistry.register(value: value, forType: Int.self)
XCTAssertEqual(value, DefaultValueRegistry.defaultValue(for: Int.self))
}
func testRegisterSet() {
let value = Set([1])
DefaultValueRegistry.register(value: value, forType: Set<Int>.self)
XCTAssertEqual(value, DefaultValueRegistry.defaultValue(for: Set<Int>.self))
}
func testRegisterArray() {
let value = [1]
DefaultValueRegistry.register(value: value, forType: Array<Int>.self)
XCTAssertEqual(value, DefaultValueRegistry.defaultValue(for: Array<Int>.self))
}
func testRegisterDictionary() {
let value = ["A": 1]
DefaultValueRegistry.register(value: value, forType: Dictionary<String, Int>.self)
XCTAssertEqual(value, DefaultValueRegistry.defaultValue(for: Dictionary<String, Int>.self))
}
func testRegisterOptional() {
let value = 1 as Int?
DefaultValueRegistry.register(value: value, forType: Optional<Int>.self)
XCTAssertEqual(value, DefaultValueRegistry.defaultValue(for: Optional<Int>.self))
}
func testRegisterTuple1() {
let value = (1)
DefaultValueRegistry.register(value: value, forType: (Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int).self))
}
func testRegisterTuple2() {
let value = (1, 1)
DefaultValueRegistry.register(value: value, forType: (Int, Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int, Int).self))
}
func testRegisterTuple3() {
let value = (1, 1, 1)
DefaultValueRegistry.register(value: value, forType: (Int, Int, Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int, Int, Int).self))
}
func testRegisterTuple4() {
let value = (1, 1, 1, 1)
DefaultValueRegistry.register(value: value, forType: (Int, Int, Int, Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int, Int, Int, Int).self))
}
func testRegisterTuple5() {
let value = (1, 1, 1, 1, 1)
DefaultValueRegistry.register(value: value, forType: (Int, Int, Int, Int, Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int, Int, Int, Int, Int).self))
}
func testRegisterTuple6() {
let value = (1, 1, 1, 1, 1, 1)
DefaultValueRegistry.register(value: value, forType: (Int, Int, Int, Int, Int, Int).self)
XCTAssertTrue(value == DefaultValueRegistry.defaultValue(for: (Int, Int, Int, Int, Int, Int).self))
}
}