-
Notifications
You must be signed in to change notification settings - Fork 104
/
StringBoxTests.swift
73 lines (62 loc) · 1.48 KB
/
StringBoxTests.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
//
// StringBoxTests.swift
// XMLCoderTests
//
// Created by Vincent Esche on 12/18/18.
//
import XCTest
@testable import XMLCoder
class StringBoxTests: XCTestCase {
typealias Boxed = StringBox
func testIsNull() {
let box = Boxed("lorem ipsum")
XCTAssertEqual(box.isNull, false)
}
func testUnbox() {
let values: [Boxed.Unboxed] = [
"",
"false",
"42",
"12.34",
"lorem ipsum",
]
for unboxed in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.unbox(), unboxed)
}
}
func testXMLString() {
let values: [(Boxed.Unboxed, String)] = [
("", ""),
("false", "false"),
("42", "42"),
("12.34", "12.34"),
("lorem ipsum", "lorem ipsum"),
]
for (unboxed, string) in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.xmlString(), string)
}
}
func testValidValues() {
let values: [String] = [
"0",
"1",
"false",
"true",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNotNil(box)
}
}
func testInvalidValues() {
let values: [String] = [
// none.
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNil(box)
}
}
}