|
10 | 10 | // |
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
13 | | -#if canImport(TestSupport) |
14 | | -import TestSupport |
15 | | -#endif |
16 | 13 |
|
17 | | -#if FOUNDATION_FRAMEWORK |
18 | | -@testable import Foundation |
19 | | -#else |
| 14 | +import Testing |
| 15 | + |
| 16 | +#if canImport(FoundationEssentials) |
20 | 17 | @testable import FoundationEssentials |
21 | | -#endif // FOUNDATION_FRAMEWORK |
| 18 | +#else |
| 19 | +@testable import Foundation |
| 20 | +#endif |
22 | 21 |
|
23 | | -class SortComparatorTests: XCTestCase { |
24 | | - func test_comparable_descriptors() { |
| 22 | +@Suite("SortComparator") |
| 23 | +private struct SortComparatorTests { |
| 24 | + @Test func comparableDescriptors() { |
25 | 25 | let intDesc: ComparableComparator<Int> = ComparableComparator<Int>() |
26 | | - XCTAssertEqual(intDesc.compare(0, 1), .orderedAscending) |
| 26 | + #expect(intDesc.compare(0, 1) == .orderedAscending) |
27 | 27 | let result = intDesc.compare(1000, -10) |
28 | | - XCTAssertEqual(result, .orderedDescending) |
| 28 | + #expect(result == .orderedDescending) |
29 | 29 | } |
30 | 30 |
|
31 | 31 |
|
32 | | - func test_order() { |
| 32 | + @Test func order() { |
33 | 33 | var intDesc: ComparableComparator<Int> = ComparableComparator<Int>(order: .reverse) |
34 | | - XCTAssertEqual(intDesc.compare(0, 1), .orderedDescending) |
35 | | - XCTAssertEqual(intDesc.compare(1000, -10), .orderedAscending) |
36 | | - XCTAssertEqual(intDesc.compare(100, 100), .orderedSame) |
| 34 | + #expect(intDesc.compare(0, 1) == .orderedDescending) |
| 35 | + #expect(intDesc.compare(1000, -10) == .orderedAscending) |
| 36 | + #expect(intDesc.compare(100, 100) == .orderedSame) |
37 | 37 |
|
38 | 38 | intDesc.order = .forward |
39 | | - XCTAssertEqual(intDesc.compare(0, 1), .orderedAscending) |
40 | | - XCTAssertEqual(intDesc.compare(1000, -10), .orderedDescending) |
41 | | - XCTAssertEqual(intDesc.compare(100, 100), .orderedSame) |
42 | | - } |
43 | | - |
44 | | - func test_compare_options_descriptor() { |
45 | | - let compareOptions = String.Comparator(options: [.numeric]) |
46 | | - XCTAssertEqual( |
47 | | - compareOptions.compare("ttestest005", "test2"), |
48 | | - "test005".compare("test2", options: [.numeric])) |
49 | | - XCTAssertEqual( |
50 | | - compareOptions.compare("test2", "test005"), |
51 | | - "test2".compare("test005", options: [.numeric])) |
| 39 | + #expect(intDesc.compare(0, 1) == .orderedAscending) |
| 40 | + #expect(intDesc.compare(1000, -10) == .orderedDescending) |
| 41 | + #expect(intDesc.compare(100, 100) == .orderedSame) |
52 | 42 | } |
53 | 43 |
|
54 | | - func testAnySortComparatorEquality() { |
| 44 | + @Test func anySortComparatorEquality() { |
55 | 45 | let a: ComparableComparator<Int> = ComparableComparator<Int>() |
56 | 46 | let b: ComparableComparator<Int> = ComparableComparator<Int>(order: .reverse) |
57 | 47 | let c: ComparableComparator<Double> = ComparableComparator<Double>() |
58 | | - XCTAssertEqual(AnySortComparator(a), AnySortComparator(a)) |
59 | | - XCTAssertEqual(AnySortComparator(b), AnySortComparator(b)) |
60 | | - XCTAssertEqual(AnySortComparator(c), AnySortComparator(c)) |
61 | | - XCTAssertNotEqual(AnySortComparator(a), AnySortComparator(b)) |
62 | | - XCTAssertNotEqual(AnySortComparator(b), AnySortComparator(c)) |
63 | | - XCTAssertNotEqual(AnySortComparator(a), AnySortComparator(c)) |
| 48 | + #expect(AnySortComparator(a) == AnySortComparator(a)) |
| 49 | + #expect(AnySortComparator(b) == AnySortComparator(b)) |
| 50 | + #expect(AnySortComparator(c) == AnySortComparator(c)) |
| 51 | + #expect(AnySortComparator(a) != AnySortComparator(b)) |
| 52 | + #expect(AnySortComparator(b) != AnySortComparator(c)) |
| 53 | + #expect(AnySortComparator(a) != AnySortComparator(c)) |
64 | 54 | } |
65 | 55 | } |
0 commit comments