Skip to content

Commit 9d202a6

Browse files
committed
refactor: convert Swift Testing to backtick syntax
Convert @suite and @test declarations to use Swift 6.2 backtick syntax: - @suite("Name") struct Foo → @suite struct `Name` - @test("Description") func test() → @test func `Description`() - @test("Desc", arguments: [...]) → @test(arguments: [...]) func `Desc`() This leverages Swift 6.2's support for backticks in identifiers, making test names more readable and eliminating duplicate strings.
1 parent e5f36b9 commit 9d202a6

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

Tests/RFC 1123 Tests/RFC 1123 Tests.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,102 +8,102 @@
88
import RFC_1123
99
import Testing
1010

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 {
1515
let host = try Domain("host.example.com")
1616
#expect(host.name == "host.example.com")
1717
}
1818

19-
@Test("Successfully creates host with numeric labels")
20-
func testNumericLabels() throws {
19+
@Test
20+
func `Successfully creates host with numeric labels`() throws {
2121
let host = try Domain("123.example.com")
2222
#expect(host.name == "123.example.com")
2323
}
2424

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 {
2727
let host = try Domain("host123.example456.com")
2828
#expect(host.name == "host123.example456.com")
2929
}
3030

31-
@Test("Fails with empty host")
32-
func testEmptyHost() throws {
31+
@Test
32+
func `Fails with empty host`() throws {
3333
#expect(throws: Domain.ValidationError.empty) {
3434
_ = try Domain("")
3535
}
3636
}
3737

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 {
4040
#expect(throws: Domain.ValidationError.invalidTLD("123com")) {
4141
_ = try Domain("example.123com")
4242
}
4343
}
4444

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 {
4747
#expect(throws: Domain.ValidationError.invalidTLD("com123")) {
4848
_ = try Domain("example.com123")
4949
}
5050
}
5151

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 {
5454
#expect(throws: Domain.ValidationError.invalidLabel("host@name")) {
5555
_ = try Domain("[email protected]")
5656
}
5757
}
5858

59-
@Test("Successfully gets TLD")
60-
func testTLD() throws {
59+
@Test
60+
func `Successfully gets TLD`() throws {
6161
let host = try Domain("example.com")
6262
#expect(host.tld?.stringValue == "com")
6363
}
6464

65-
@Test("Successfully gets SLD")
66-
func testSLD() throws {
65+
@Test
66+
func `Successfully gets SLD`() throws {
6767
let host = try Domain("example.com")
6868
#expect(host.sld?.stringValue == "example")
6969
}
7070

71-
@Test("Successfully detects subdomain relationship")
72-
func testIsSubdomain() throws {
71+
@Test
72+
func `Successfully detects subdomain relationship`() throws {
7373
let parent = try Domain("example.com")
7474
let child = try Domain("host.example.com")
7575
#expect(child.isSubdomain(of: parent))
7676
}
7777

78-
@Test("Successfully adds subdomain")
79-
func testAddSubdomain() throws {
78+
@Test
79+
func `Successfully adds subdomain`() throws {
8080
let host = try Domain("example.com")
8181
let subdomain = try host.addingSubdomain("host")
8282
#expect(subdomain.name == "host.example.com")
8383
}
8484

85-
@Test("Successfully gets parent domain")
86-
func testParentDomain() throws {
85+
@Test
86+
func `Successfully gets parent domain`() throws {
8787
let host = try Domain("host.example.com")
8888
let parent = try host.parent()
8989
#expect(parent?.name == "example.com")
9090
}
9191

92-
@Test("Successfully gets root domain")
93-
func testRootDomain() throws {
92+
@Test
93+
func `Successfully gets root domain`() throws {
9494
let host = try Domain("host.example.com")
9595
let root = try host.root()
9696
#expect(root?.name == "example.com")
9797
}
9898

99-
@Test("Successfully creates host from root components")
100-
func testRootInitializer() throws {
99+
@Test
100+
func `Successfully creates host from root components`() throws {
101101
let host = try Domain.root("example", "com")
102102
#expect(host.name == "example.com")
103103
}
104104

105-
@Test("Successfully creates host from subdomain components")
106-
func testSubdomainInitializer() throws {
105+
@Test
106+
func `Successfully creates host from subdomain components`() throws {
107107
let host = try Domain.subdomain("com", "example", "host")
108108
#expect(host.name == "host.example.com")
109109
}

Tests/RFC 1123 Tests/ReadmeVerificationTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,48 @@ import RFC_1035
99
import RFC_1123
1010
import Testing
1111

12-
@Suite("README Verification")
13-
struct ReadmeVerificationTests {
12+
@Suite
13+
struct `README Verification` {
1414

15-
@Test("README Line 53: Create from string")
16-
func createFromString() throws {
15+
@Test
16+
func `README Line 53: Create from string`() throws {
1717
let host = try RFC_1123.Domain("example.com")
1818

1919
#expect(host.name == "example.com")
2020
}
2121

22-
@Test("README Line 55-56: RFC 1123 allows labels starting with digits")
23-
func numericLabels() throws {
22+
@Test
23+
func `README Line 55-56: RFC 1123 allows labels starting with digits`() throws {
2424
let numericHost = try RFC_1123.Domain("123.example.com")
2525

2626
#expect(numericHost.name == "123.example.com")
2727
}
2828

29-
@Test("README Line 58-59: Create from root components")
30-
func createFromRootComponents() throws {
29+
@Test
30+
func `README Line 58-59: Create from root components`() throws {
3131
let host = try RFC_1123.Domain.root("example", "com")
3232

3333
#expect(host.name == "example.com")
3434
}
3535

36-
@Test("README Line 61-63: Create subdomain with reversed components")
37-
func createSubdomainReversed() throws {
36+
@Test
37+
func `README Line 61-63: Create subdomain with reversed components`() throws {
3838
let host = try RFC_1123.Domain.subdomain("com", "example", "api")
3939

4040
#expect(host.name == "api.example.com")
4141
}
4242

43-
@Test("README Line 69-76: Working with domain components")
44-
func workingWithComponents() throws {
43+
@Test
44+
func `README Line 69-76: Working with domain components`() throws {
4545
let host = try RFC_1123.Domain("api.example.com")
4646

4747
#expect(host.tld?.stringValue == "com")
4848
#expect(host.sld?.stringValue == "example")
4949
#expect(host.name == "api.example.com")
5050
}
5151

52-
@Test("README Line 82-99: Domain hierarchy navigation")
53-
func domainHierarchyNavigation() throws {
52+
@Test
53+
func `README Line 82-99: Domain hierarchy navigation`() throws {
5454
let host = try RFC_1123.Domain("api.v1.example.com")
5555

5656
// Get parent domain
@@ -71,8 +71,8 @@ struct ReadmeVerificationTests {
7171
#expect(childDomain.isSubdomain(of: parentDomain))
7272
}
7373

74-
@Test("README Line 105-113: RFC 1035 interoperability")
75-
func rfc1035Interoperability() throws {
74+
@Test
75+
func `README Line 105-113: RFC 1035 interoperability`() throws {
7676
// Convert RFC 1035 domain to RFC 1123
7777
let rfc1035Domain = try RFC_1035.Domain("example.com")
7878
let rfc1123Domain = try RFC_1123.Domain(rfc1035Domain)
@@ -85,8 +85,8 @@ struct ReadmeVerificationTests {
8585
#expect(backToRFC1035.name == "example.com")
8686
}
8787

88-
@Test("README Line 166-178: Error handling")
89-
func errorHandling() throws {
88+
@Test
89+
func `README Line 166-178: Error handling`() throws {
9090
// Empty host
9191
#expect(throws: RFC_1123.Domain.ValidationError.empty) {
9292
_ = try RFC_1123.Domain("")

0 commit comments

Comments
 (0)