Skip to content

Commit a11cadd

Browse files
committed
Create XMLHeaderTests.swift
1 parent c37e9e8 commit a11cadd

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// XMLHeaderTests.swift
3+
//
4+
// Copyright (c) 2016 - 2025 Nuno Dias
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
24+
import Testing
25+
import XMLKit
26+
27+
@Suite("XMLHeader")
28+
struct XMLHeaderTests: XMLKitTestable {
29+
@Test
30+
func `default`() throws {
31+
// Given
32+
let header: XMLHeader = .default
33+
let expected = """
34+
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
35+
"""
36+
37+
// When
38+
let actual = header.toXMLString()
39+
40+
// Then
41+
#expect(expected == actual)
42+
}
43+
44+
@Test
45+
func version() throws {
46+
// Given
47+
let header: XMLHeader = .init(version: "1.1")
48+
let expected = """
49+
<?xml version=\"1.1\" encoding=\"UTF-8\"?>
50+
"""
51+
52+
// When
53+
let actual = header.toXMLString()
54+
55+
// Then
56+
#expect(expected == actual)
57+
}
58+
59+
@Test
60+
func encoding() throws {
61+
// Given
62+
let header: XMLHeader = .init(encoding: .utf16)
63+
let expected = """
64+
<?xml version=\"1.0\" encoding=\"UTF-16\"?>
65+
"""
66+
67+
// When
68+
let actual = header.toXMLString()
69+
70+
// Then
71+
#expect(expected == actual)
72+
}
73+
74+
@Test
75+
func isStandalone() throws {
76+
// Given
77+
let header: XMLHeader = .init(version: "1.0", isStandalone: true)
78+
let expected = """
79+
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
80+
"""
81+
82+
// When
83+
let actual = header.toXMLString()
84+
85+
// Then
86+
#expect(expected == actual)
87+
}
88+
}

0 commit comments

Comments
 (0)