Skip to content

Commit 53448db

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 ca38b78 commit 53448db

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

Tests/RFC 1035 Tests/RFC 1035 Tests.swift

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,112 +8,112 @@
88
import RFC_1035
99
import Testing
1010

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

19-
@Test("Successfully creates subdomain")
20-
func testValidSubdomain() throws {
19+
@Test
20+
func `Successfully creates subdomain`() throws {
2121
let domain = try Domain("sub.example.com")
2222
#expect(domain.name == "sub.example.com")
2323
}
2424

25-
@Test("Successfully gets TLD")
26-
func testTLD() throws {
25+
@Test
26+
func `Successfully gets TLD`() throws {
2727
let domain = try Domain("example.com")
2828
#expect(domain.tld?.stringValue == "com")
2929
}
3030

31-
@Test("Successfully gets SLD")
32-
func testSLD() throws {
31+
@Test
32+
func `Successfully gets SLD`() throws {
3333
let domain = try Domain("example.com")
3434
#expect(domain.sld?.stringValue == "example")
3535
}
3636

37-
@Test("Fails with empty domain")
38-
func testEmptyDomain() throws {
37+
@Test
38+
func `Fails with empty domain`() throws {
3939
#expect(throws: Domain.ValidationError.empty) {
4040
_ = try Domain("")
4141
}
4242
}
4343

44-
@Test("Fails with too many labels")
45-
func testTooManyLabels() throws {
44+
@Test
45+
func `Fails with too many labels`() throws {
4646
let longDomain = Array(repeating: "a", count: 128).joined(separator: ".")
4747
#expect(throws: Domain.ValidationError.tooManyLabels) {
4848
_ = try Domain(longDomain)
4949
}
5050
}
5151

52-
@Test("Fails with too long domain")
53-
func testTooLongDomain() throws {
52+
@Test
53+
func `Fails with too long domain`() throws {
5454
let longLabel = String(repeating: "a", count: 63)
5555
let longDomain = Array(repeating: longLabel, count: 5).joined(separator: ".")
5656
#expect(throws: Domain.ValidationError.tooLong(319)) {
5757
_ = try Domain(longDomain)
5858
}
5959
}
6060

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 {
6363
#expect(throws: Domain.ValidationError.invalidLabel("-example")) {
6464
_ = try Domain("-example.com")
6565
}
6666
}
6767

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 {
7070
#expect(throws: Domain.ValidationError.invalidLabel("example-")) {
7171
_ = try Domain("example-.com")
7272
}
7373
}
7474

75-
@Test("Successfully detects subdomain relationship")
76-
func testIsSubdomain() throws {
75+
@Test
76+
func `Successfully detects subdomain relationship`() throws {
7777
let parent = try Domain("example.com")
7878
let child = try Domain("sub.example.com")
7979
#expect(child.isSubdomain(of: parent))
8080
}
8181

82-
@Test("Successfully adds subdomain")
83-
func testAddSubdomain() throws {
82+
@Test
83+
func `Successfully adds subdomain`() throws {
8484
let domain = try Domain("example.com")
8585
let subdomain = try domain.addingSubdomain("sub")
8686
#expect(subdomain.name == "sub.example.com")
8787
}
8888

89-
@Test("Successfully gets parent domain")
90-
func testParentDomain() throws {
89+
@Test
90+
func `Successfully gets parent domain`() throws {
9191
let domain = try Domain("sub.example.com")
9292
let parent = try domain.parent()
9393
#expect(parent?.name == "example.com")
9494
}
9595

96-
@Test("Successfully gets root domain")
97-
func testRootDomain() throws {
96+
@Test
97+
func `Successfully gets root domain`() throws {
9898
let domain = try Domain("sub.example.com")
9999
let root = try domain.root()
100100
#expect(root?.name == "example.com")
101101
}
102102

103-
@Test("Successfully creates domain from root components")
104-
func testRootInitializer() throws {
103+
@Test
104+
func `Successfully creates domain from root components`() throws {
105105
let domain = try Domain.root("example", "com")
106106
#expect(domain.name == "example.com")
107107
}
108108

109-
@Test("Successfully creates domain from subdomain components")
110-
func testSubdomainInitializer() throws {
109+
@Test
110+
func `Successfully creates domain from subdomain components`() throws {
111111
let domain = try Domain.subdomain("com", "example", "sub")
112112
#expect(domain.name == "sub.example.com")
113113
}
114114

115-
@Test("Successfully encodes and decodes")
116-
func testCodable() throws {
115+
@Test
116+
func `Successfully encodes and decodes`() throws {
117117
let original = try Domain("example.com")
118118
let encoded = try JSONEncoder().encode(original)
119119
let decoded = try JSONDecoder().decode(Domain.self, from: encoded)

Tests/RFC 1035 Tests/ReadmeVerificationTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,41 @@ import RFC_1035
99
import Testing
1010
import Foundation
1111

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

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

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

22-
@Test("README Line 54-55: Create from root components")
23-
func createFromRootComponents() throws {
22+
@Test
23+
func `README Line 54-55: Create from root components`() throws {
2424
let domain = try Domain.root("example", "com")
2525

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

29-
@Test("README Line 57-59: Create subdomain with reversed components")
30-
func createSubdomainReversed() throws {
29+
@Test
30+
func `README Line 57-59: Create subdomain with reversed components`() throws {
3131
let domain = try Domain.subdomain("com", "example", "api")
3232

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

36-
@Test("README Line 65-72: Working with domain components")
37-
func workingWithComponents() throws {
36+
@Test
37+
func `README Line 65-72: Working with domain components`() throws {
3838
let domain = try Domain("api.example.com")
3939

4040
#expect(domain.tld?.stringValue == "com")
4141
#expect(domain.sld?.stringValue == "example")
4242
#expect(domain.name == "api.example.com")
4343
}
4444

45-
@Test("README Line 78-95: Domain hierarchy navigation")
46-
func domainHierarchyNavigation() throws {
45+
@Test
46+
func `README Line 78-95: Domain hierarchy navigation`() throws {
4747
let domain = try Domain("api.v1.example.com")
4848

4949
// Get parent domain
@@ -64,8 +64,8 @@ struct ReadmeVerificationTests {
6464
#expect(childDomain.isSubdomain(of: parentDomain))
6565
}
6666

67-
@Test("README Line 136-146: Error handling")
68-
func errorHandling() throws {
67+
@Test
68+
func `README Line 136-146: Error handling`() throws {
6969
// Empty domain
7070
#expect(throws: Domain.ValidationError.empty) {
7171
_ = try Domain("")
@@ -77,8 +77,8 @@ struct ReadmeVerificationTests {
7777
}
7878
}
7979

80-
@Test("README Line 151-158: Codable support")
81-
func codableSupport() throws {
80+
@Test
81+
func `README Line 151-158: Codable support`() throws {
8282
let domain = try Domain("example.com")
8383

8484
// Encode to JSON

0 commit comments

Comments
 (0)