-
Notifications
You must be signed in to change notification settings - Fork 104
/
URLBoxTests.swift
61 lines (51 loc) · 1.36 KB
/
URLBoxTests.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
//
// URLBoxTests.swift
// XMLCoderTests
//
// Created by Vincent Esche on 12/21/18.
//
import XCTest
@testable import XMLCoder
class URLBoxTests: XCTestCase {
typealias Boxed = URLBox
func testUnbox() {
let values: [Boxed.Unboxed] = [
URL(string: "file:///")!,
URL(string: "http://example.com")!,
]
for unboxed in values {
let box = Boxed(unboxed)
XCTAssertEqual(box.unbox(), unboxed)
}
}
func testXMLString() {
let values: [(Boxed.Unboxed, String)] = [
(URL(string: "file:///")!, "file:///"),
(URL(string: "http://example.com")!, "http://example.com"),
]
for (bool, string) in values {
let box = Boxed(bool)
XCTAssertEqual(box.xmlString(), string)
}
}
func testValidValues() {
let values: [String] = [
"file:///",
"http://example.com",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNotNil(box)
}
}
func testInvalidValues() {
let values: [String] = [
"foo\nbar",
"",
]
for string in values {
let box = Boxed(xmlString: string)
XCTAssertNil(box)
}
}
}