|
8 | 8 | import RFC_1035 |
9 | 9 | import Testing |
10 | 10 |
|
11 | | -@Suite("RFC 1035 Domain Tests") |
12 | | -struct RFC1035Tests { |
13 | | - @Test("Successfully creates valid domain") |
14 | | - func testValidDomain() throws { |
| 11 | +@Suite |
| 12 | +struct `RFC 1035 Domain Tests` { |
| 13 | + @Test |
| 14 | + func `Successfully creates valid domain`() throws { |
15 | 15 | let domain = try Domain("example.com") |
16 | 16 | #expect(domain.name == "example.com") |
17 | 17 | } |
18 | 18 |
|
19 | | - @Test("Successfully creates subdomain") |
20 | | - func testValidSubdomain() throws { |
| 19 | + @Test |
| 20 | + func `Successfully creates subdomain`() throws { |
21 | 21 | let domain = try Domain("sub.example.com") |
22 | 22 | #expect(domain.name == "sub.example.com") |
23 | 23 | } |
24 | 24 |
|
25 | | - @Test("Successfully gets TLD") |
26 | | - func testTLD() throws { |
| 25 | + @Test |
| 26 | + func `Successfully gets TLD`() throws { |
27 | 27 | let domain = try Domain("example.com") |
28 | 28 | #expect(domain.tld?.stringValue == "com") |
29 | 29 | } |
30 | 30 |
|
31 | | - @Test("Successfully gets SLD") |
32 | | - func testSLD() throws { |
| 31 | + @Test |
| 32 | + func `Successfully gets SLD`() throws { |
33 | 33 | let domain = try Domain("example.com") |
34 | 34 | #expect(domain.sld?.stringValue == "example") |
35 | 35 | } |
36 | 36 |
|
37 | | - @Test("Fails with empty domain") |
38 | | - func testEmptyDomain() throws { |
| 37 | + @Test |
| 38 | + func `Fails with empty domain`() throws { |
39 | 39 | #expect(throws: Domain.ValidationError.empty) { |
40 | 40 | _ = try Domain("") |
41 | 41 | } |
42 | 42 | } |
43 | 43 |
|
44 | | - @Test("Fails with too many labels") |
45 | | - func testTooManyLabels() throws { |
| 44 | + @Test |
| 45 | + func `Fails with too many labels`() throws { |
46 | 46 | let longDomain = Array(repeating: "a", count: 128).joined(separator: ".") |
47 | 47 | #expect(throws: Domain.ValidationError.tooManyLabels) { |
48 | 48 | _ = try Domain(longDomain) |
49 | 49 | } |
50 | 50 | } |
51 | 51 |
|
52 | | - @Test("Fails with too long domain") |
53 | | - func testTooLongDomain() throws { |
| 52 | + @Test |
| 53 | + func `Fails with too long domain`() throws { |
54 | 54 | let longLabel = String(repeating: "a", count: 63) |
55 | 55 | let longDomain = Array(repeating: longLabel, count: 5).joined(separator: ".") |
56 | 56 | #expect(throws: Domain.ValidationError.tooLong(319)) { |
57 | 57 | _ = try Domain(longDomain) |
58 | 58 | } |
59 | 59 | } |
60 | 60 |
|
61 | | - @Test("Fails with invalid label starting with hyphen") |
62 | | - func testInvalidLabelStartingWithHyphen() throws { |
| 61 | + @Test |
| 62 | + func `Fails with invalid label starting with hyphen`() throws { |
63 | 63 | #expect(throws: Domain.ValidationError.invalidLabel("-example")) { |
64 | 64 | _ = try Domain("-example.com") |
65 | 65 | } |
66 | 66 | } |
67 | 67 |
|
68 | | - @Test("Fails with invalid label ending with hyphen") |
69 | | - func testInvalidLabelEndingWithHyphen() throws { |
| 68 | + @Test |
| 69 | + func `Fails with invalid label ending with hyphen`() throws { |
70 | 70 | #expect(throws: Domain.ValidationError.invalidLabel("example-")) { |
71 | 71 | _ = try Domain("example-.com") |
72 | 72 | } |
73 | 73 | } |
74 | 74 |
|
75 | | - @Test("Successfully detects subdomain relationship") |
76 | | - func testIsSubdomain() throws { |
| 75 | + @Test |
| 76 | + func `Successfully detects subdomain relationship`() throws { |
77 | 77 | let parent = try Domain("example.com") |
78 | 78 | let child = try Domain("sub.example.com") |
79 | 79 | #expect(child.isSubdomain(of: parent)) |
80 | 80 | } |
81 | 81 |
|
82 | | - @Test("Successfully adds subdomain") |
83 | | - func testAddSubdomain() throws { |
| 82 | + @Test |
| 83 | + func `Successfully adds subdomain`() throws { |
84 | 84 | let domain = try Domain("example.com") |
85 | 85 | let subdomain = try domain.addingSubdomain("sub") |
86 | 86 | #expect(subdomain.name == "sub.example.com") |
87 | 87 | } |
88 | 88 |
|
89 | | - @Test("Successfully gets parent domain") |
90 | | - func testParentDomain() throws { |
| 89 | + @Test |
| 90 | + func `Successfully gets parent domain`() throws { |
91 | 91 | let domain = try Domain("sub.example.com") |
92 | 92 | let parent = try domain.parent() |
93 | 93 | #expect(parent?.name == "example.com") |
94 | 94 | } |
95 | 95 |
|
96 | | - @Test("Successfully gets root domain") |
97 | | - func testRootDomain() throws { |
| 96 | + @Test |
| 97 | + func `Successfully gets root domain`() throws { |
98 | 98 | let domain = try Domain("sub.example.com") |
99 | 99 | let root = try domain.root() |
100 | 100 | #expect(root?.name == "example.com") |
101 | 101 | } |
102 | 102 |
|
103 | | - @Test("Successfully creates domain from root components") |
104 | | - func testRootInitializer() throws { |
| 103 | + @Test |
| 104 | + func `Successfully creates domain from root components`() throws { |
105 | 105 | let domain = try Domain.root("example", "com") |
106 | 106 | #expect(domain.name == "example.com") |
107 | 107 | } |
108 | 108 |
|
109 | | - @Test("Successfully creates domain from subdomain components") |
110 | | - func testSubdomainInitializer() throws { |
| 109 | + @Test |
| 110 | + func `Successfully creates domain from subdomain components`() throws { |
111 | 111 | let domain = try Domain.subdomain("com", "example", "sub") |
112 | 112 | #expect(domain.name == "sub.example.com") |
113 | 113 | } |
114 | 114 |
|
115 | | - @Test("Successfully encodes and decodes") |
116 | | - func testCodable() throws { |
| 115 | + @Test |
| 116 | + func `Successfully encodes and decodes`() throws { |
117 | 117 | let original = try Domain("example.com") |
118 | 118 | let encoded = try JSONEncoder().encode(original) |
119 | 119 | let decoded = try JSONDecoder().decode(Domain.self, from: encoded) |
|
0 commit comments