|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2021-2025 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2021 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception
|
7 | 7 | //
|
8 | 8 | // See http://swift.org/LICENSE.txt for license information
|
9 | 9 | // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 |
| -import Foundation |
13 | 12 |
|
14 | 13 | @testable import Basics
|
15 |
| -import Testing |
| 14 | +import XCTest |
16 | 15 |
|
17 |
| -struct EnvironmentKeyTests { |
18 |
| - @Test |
19 |
| - func comparable() { |
| 16 | +final class EnvironmentKeyTests: XCTestCase { |
| 17 | + func test_comparable() { |
20 | 18 | let key0 = EnvironmentKey("Test")
|
21 | 19 | let key1 = EnvironmentKey("Test1")
|
22 |
| - #expect(key0 < key1) |
| 20 | + XCTAssertLessThan(key0, key1) |
23 | 21 |
|
24 | 22 | let key2 = EnvironmentKey("test")
|
25 |
| - #expect(key0 < key2) |
| 23 | + XCTAssertLessThan(key0, key2) |
26 | 24 | }
|
27 | 25 |
|
28 |
| - @Test |
29 |
| - func customStringConvertible() { |
| 26 | + func test_customStringConvertible() { |
30 | 27 | let key = EnvironmentKey("Test")
|
31 |
| - #expect(key.description == "Test") |
| 28 | + XCTAssertEqual(key.description, "Test") |
32 | 29 | }
|
33 | 30 |
|
34 |
| - @Test |
35 |
| - func encodable() throws { |
| 31 | + func test_encodable() throws { |
36 | 32 | let key = EnvironmentKey("Test")
|
37 | 33 | let data = try JSONEncoder().encode(key)
|
38 | 34 | let string = String(data: data, encoding: .utf8)
|
39 |
| - #expect(string == #""Test""#) |
| 35 | + XCTAssertEqual(string, #""Test""#) |
40 | 36 | }
|
41 | 37 |
|
42 |
| - @Test |
43 |
| - func equatable() { |
| 38 | + func test_equatable() { |
44 | 39 | let key0 = EnvironmentKey("Test")
|
45 | 40 | let key1 = EnvironmentKey("Test")
|
46 |
| - #expect(key0 == key1) |
| 41 | + XCTAssertEqual(key0, key1) |
47 | 42 |
|
48 | 43 | let key2 = EnvironmentKey("Test2")
|
49 |
| - #expect(key0 != key2) |
| 44 | + XCTAssertNotEqual(key0, key2) |
50 | 45 |
|
51 | 46 | #if os(Windows)
|
52 | 47 | // Test case insensitivity on windows
|
53 | 48 | let key3 = EnvironmentKey("teSt")
|
54 |
| - #expect(key0 == key3) |
| 49 | + XCTAssertEqual(key0, key3) |
55 | 50 | #endif
|
56 | 51 | }
|
57 | 52 |
|
58 |
| - @Test |
59 |
| - func expressibleByStringLiteral() { |
| 53 | + func test_expressibleByStringLiteral() { |
60 | 54 | let key0 = EnvironmentKey("Test")
|
61 |
| - #expect(key0 == "Test") |
| 55 | + XCTAssertEqual(key0, "Test") |
62 | 56 | }
|
63 | 57 |
|
64 |
| - @Test |
65 |
| - func decodable() throws { |
| 58 | + func test_decodable() throws { |
66 | 59 | let jsonString = #""Test""#
|
67 | 60 | let data = jsonString.data(using: .utf8)!
|
68 | 61 | let key = try JSONDecoder().decode(EnvironmentKey.self, from: data)
|
69 |
| - #expect(key.rawValue == "Test") |
| 62 | + XCTAssertEqual(key.rawValue, "Test") |
70 | 63 | }
|
71 | 64 |
|
72 |
| - @Test |
73 |
| - func hashable() { |
| 65 | + func test_hashable() { |
74 | 66 | var set = Set<EnvironmentKey>()
|
75 | 67 | let key0 = EnvironmentKey("Test")
|
76 |
| - #expect(set.insert(key0).inserted) |
| 68 | + XCTAssertTrue(set.insert(key0).inserted) |
77 | 69 |
|
78 | 70 | let key1 = EnvironmentKey("Test")
|
79 |
| - #expect(set.contains(key1)) |
80 |
| - #expect(!set.insert(key1).inserted) |
| 71 | + XCTAssertTrue(set.contains(key1)) |
| 72 | + XCTAssertFalse(set.insert(key1).inserted) |
81 | 73 |
|
82 | 74 | let key2 = EnvironmentKey("Test2")
|
83 |
| - #expect(!set.contains(key2)) |
84 |
| - #expect(set.insert(key2).inserted) |
| 75 | + XCTAssertFalse(set.contains(key2)) |
| 76 | + XCTAssertTrue(set.insert(key2).inserted) |
85 | 77 |
|
86 | 78 | #if os(Windows)
|
87 | 79 | // Test case insensitivity on windows
|
88 | 80 | let key3 = EnvironmentKey("teSt")
|
89 |
| - #expect(set.contains(key3)) |
90 |
| - #expect(!set.insert(key3).inserted) |
| 81 | + XCTAssertTrue(set.contains(key3)) |
| 82 | + XCTAssertFalse(set.insert(key3).inserted) |
91 | 83 | #endif
|
92 | 84 |
|
93 |
| - #expect(set == ["Test", "Test2"]) |
| 85 | + XCTAssertEqual(set, ["Test", "Test2"]) |
94 | 86 | }
|
95 | 87 |
|
96 |
| - @Test |
97 |
| - func rawRepresentable() { |
| 88 | + func test_rawRepresentable() { |
98 | 89 | let key = EnvironmentKey(rawValue: "Test")
|
99 |
| - #expect(key?.rawValue == "Test") |
| 90 | + XCTAssertEqual(key?.rawValue, "Test") |
100 | 91 | }
|
101 | 92 | }
|
0 commit comments