|
8 | 8 | import RFC_1123 |
9 | 9 | import Testing |
10 | 10 |
|
11 | | -@Suite("RFC 1123 Host Tests") |
12 | | -struct RFC1123Tests { |
13 | | - @Test("Successfully creates valid host") |
14 | | - func testValidHost() throws { |
| 11 | +@Suite |
| 12 | +struct `RFC 1123 Host Tests` { |
| 13 | + @Test |
| 14 | + func `Successfully creates valid host`() throws { |
15 | 15 | let host = try Domain("host.example.com") |
16 | 16 | #expect(host.name == "host.example.com") |
17 | 17 | } |
18 | 18 |
|
19 | | - @Test("Successfully creates host with numeric labels") |
20 | | - func testNumericLabels() throws { |
| 19 | + @Test |
| 20 | + func `Successfully creates host with numeric labels`() throws { |
21 | 21 | let host = try Domain("123.example.com") |
22 | 22 | #expect(host.name == "123.example.com") |
23 | 23 | } |
24 | 24 |
|
25 | | - @Test("Successfully creates host with mixed alphanumeric labels") |
26 | | - func testMixedLabels() throws { |
| 25 | + @Test |
| 26 | + func `Successfully creates host with mixed alphanumeric labels`() throws { |
27 | 27 | let host = try Domain("host123.example456.com") |
28 | 28 | #expect(host.name == "host123.example456.com") |
29 | 29 | } |
30 | 30 |
|
31 | | - @Test("Fails with empty host") |
32 | | - func testEmptyHost() throws { |
| 31 | + @Test |
| 32 | + func `Fails with empty host`() throws { |
33 | 33 | #expect(throws: Domain.ValidationError.empty) { |
34 | 34 | _ = try Domain("") |
35 | 35 | } |
36 | 36 | } |
37 | 37 |
|
38 | | - @Test("Fails with invalid TLD starting with number") |
39 | | - func testInvalidTLDStartingWithNumber() throws { |
| 38 | + @Test |
| 39 | + func `Fails with invalid TLD starting with number`() throws { |
40 | 40 | #expect(throws: Domain.ValidationError.invalidTLD("123com")) { |
41 | 41 | _ = try Domain("example.123com") |
42 | 42 | } |
43 | 43 | } |
44 | 44 |
|
45 | | - @Test("Fails with invalid TLD ending with number") |
46 | | - func testInvalidTLDEndingWithNumber() throws { |
| 45 | + @Test |
| 46 | + func `Fails with invalid TLD ending with number`() throws { |
47 | 47 | #expect(throws: Domain.ValidationError.invalidTLD("com123")) { |
48 | 48 | _ = try Domain("example.com123") |
49 | 49 | } |
50 | 50 | } |
51 | 51 |
|
52 | | - @Test("Fails with invalid label containing special characters") |
53 | | - func testInvalidLabelSpecialChars() throws { |
| 52 | + @Test |
| 53 | + func `Fails with invalid label containing special characters`() throws { |
54 | 54 | #expect(throws: Domain.ValidationError.invalidLabel("host@name")) { |
55 | 55 | _ = try Domain("[email protected]") |
56 | 56 | } |
57 | 57 | } |
58 | 58 |
|
59 | | - @Test("Successfully gets TLD") |
60 | | - func testTLD() throws { |
| 59 | + @Test |
| 60 | + func `Successfully gets TLD`() throws { |
61 | 61 | let host = try Domain("example.com") |
62 | 62 | #expect(host.tld?.stringValue == "com") |
63 | 63 | } |
64 | 64 |
|
65 | | - @Test("Successfully gets SLD") |
66 | | - func testSLD() throws { |
| 65 | + @Test |
| 66 | + func `Successfully gets SLD`() throws { |
67 | 67 | let host = try Domain("example.com") |
68 | 68 | #expect(host.sld?.stringValue == "example") |
69 | 69 | } |
70 | 70 |
|
71 | | - @Test("Successfully detects subdomain relationship") |
72 | | - func testIsSubdomain() throws { |
| 71 | + @Test |
| 72 | + func `Successfully detects subdomain relationship`() throws { |
73 | 73 | let parent = try Domain("example.com") |
74 | 74 | let child = try Domain("host.example.com") |
75 | 75 | #expect(child.isSubdomain(of: parent)) |
76 | 76 | } |
77 | 77 |
|
78 | | - @Test("Successfully adds subdomain") |
79 | | - func testAddSubdomain() throws { |
| 78 | + @Test |
| 79 | + func `Successfully adds subdomain`() throws { |
80 | 80 | let host = try Domain("example.com") |
81 | 81 | let subdomain = try host.addingSubdomain("host") |
82 | 82 | #expect(subdomain.name == "host.example.com") |
83 | 83 | } |
84 | 84 |
|
85 | | - @Test("Successfully gets parent domain") |
86 | | - func testParentDomain() throws { |
| 85 | + @Test |
| 86 | + func `Successfully gets parent domain`() throws { |
87 | 87 | let host = try Domain("host.example.com") |
88 | 88 | let parent = try host.parent() |
89 | 89 | #expect(parent?.name == "example.com") |
90 | 90 | } |
91 | 91 |
|
92 | | - @Test("Successfully gets root domain") |
93 | | - func testRootDomain() throws { |
| 92 | + @Test |
| 93 | + func `Successfully gets root domain`() throws { |
94 | 94 | let host = try Domain("host.example.com") |
95 | 95 | let root = try host.root() |
96 | 96 | #expect(root?.name == "example.com") |
97 | 97 | } |
98 | 98 |
|
99 | | - @Test("Successfully creates host from root components") |
100 | | - func testRootInitializer() throws { |
| 99 | + @Test |
| 100 | + func `Successfully creates host from root components`() throws { |
101 | 101 | let host = try Domain.root("example", "com") |
102 | 102 | #expect(host.name == "example.com") |
103 | 103 | } |
104 | 104 |
|
105 | | - @Test("Successfully creates host from subdomain components") |
106 | | - func testSubdomainInitializer() throws { |
| 105 | + @Test |
| 106 | + func `Successfully creates host from subdomain components`() throws { |
107 | 107 | let host = try Domain.subdomain("com", "example", "host") |
108 | 108 | #expect(host.name == "host.example.com") |
109 | 109 | } |
|
0 commit comments