-
Notifications
You must be signed in to change notification settings - Fork 104
/
DecimalBoxTests.swift
70 lines (59 loc) · 1.4 KB
/
DecimalBoxTests.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
//
// DecimalBoxTests.swift
// XMLCoderTests
//
// Created by Vincent Esche on 12/18/18.
//
import XCTest
@testable import XMLCoder
class DecimalBoxTests: XCTestCase {
typealias Boxed = DecimalBox
func testIsNull() {
let box = Boxed(42.0)
XCTAssertEqual(box.isNull, false)
}
func testUnbox() {
let values: [Boxed.Unboxed] = [
-1.23,
12_678_967.543233,
+100_000.00,
210,
]
for unboxed in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.unbox(), unboxed)
}
}
func testXMLString() {
let values: [(Boxed.Unboxed, String)] = [
(12.34, "12.34"),
(0.0, "0"),
]
for (bool, string) in values {
let box = Boxed(bool)
XCTAssertEqual(box.xmlString(), string)
}
}
func testValidValues() {
let values: [String] = [
"-1.23",
"12678967.543233",
"+100000.00",
"210",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNotNil(box)
}
}
func testInvalidValues() {
let values: [String] = [
"foobar",
"",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNil(box)
}
}
}