-
Notifications
You must be signed in to change notification settings - Fork 104
/
UIntBoxTests.swift
71 lines (60 loc) · 1.42 KB
/
UIntBoxTests.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
//
// UIntBoxTests.swift
// XMLCoderTests
//
// Created by Vincent Esche on 12/18/18.
//
import XCTest
@testable import XMLCoder
class UIntBoxTests: XCTestCase {
typealias Boxed = UIntBox
func testIsNull() {
let box = Boxed(UInt(42))
XCTAssertEqual(box.isNull, false)
}
func testUnbox() {
let values: [Boxed.Unboxed] = [
1,
0,
12_678_967_543_233,
]
for unboxed in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.unbox(), unboxed)
}
}
func testXMLString() {
let values: [(Boxed.Unboxed, String)] = [
(1, "1"),
(0, "0"),
(12_678_967_543_233, "12678967543233"),
]
for (unboxed, string) in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.xmlString(), string)
}
}
func testValidValues() {
let values: [String] = [
"1",
"0",
"12678967543233",
"+100000",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNotNil(box)
}
}
func testInvalidValues() {
let values: [String] = [
"-1",
"foobar",
"",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNil(box)
}
}
}