Skip to content

Commit 8b25762

Browse files
gormsterstmontgomery
authored andcommitted
Added regression test for generic equal with accuracy
Didn't bother changing the name of the test case, though. Seemed like a big change for no real benefit. Also fixed one malformed (though still working) regex in the existing test checks.
1 parent 1f180d7 commit 8b25762

File tree

1 file changed

+38
-6
lines changed
  • Tests/Functional/NegativeAccuracyTestCase

1 file changed

+38
-6
lines changed

Tests/Functional/NegativeAccuracyTestCase/main.swift

+38-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#endif
1010

1111
// Regression test for https://github.com/apple/swift-corelibs-xctest/pull/7
12+
// and https://github.com/apple/swift-corelibs-xctest/pull/294
1213

1314
// CHECK: Test Suite 'All tests' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
1415
// CHECK: Test Suite '.*\.xctest' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
@@ -21,6 +22,10 @@ class NegativeAccuracyTestCase: XCTestCase {
2122
("test_equalWithAccuracy_fails", test_equalWithAccuracy_fails),
2223
("test_notEqualWithAccuracy_passes", test_notEqualWithAccuracy_passes),
2324
("test_notEqualWithAccuracy_fails", test_notEqualWithAccuracy_fails),
25+
("test_equalWithAccuracy_int_passes", test_equalWithAccuracy_int_passes),
26+
("test_equalWithAccuracy_int_fails", test_equalWithAccuracy_int_fails),
27+
("test_notEqualWithAccuracy_int_passes", test_notEqualWithAccuracy_int_passes),
28+
("test_notEqualWithAccuracy_int_fails", test_notEqualWithAccuracy_int_fails),
2429
]
2530
}()
2631

@@ -31,7 +36,7 @@ class NegativeAccuracyTestCase: XCTestCase {
3136
}
3237

3338
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_fails' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
34-
// CHECK: .*[/\\]NegativeAccuracyTestCase[/\\]main.swift:[[@LINE+3]]: error: NegativeAccuracyTestCase.test_equalWithAccuracy_fails : XCTAssertEqual failed: \(\"0\.0\"\) is not equal to \(\"0\.2\"\) \+\/- \(\"-0\.1\"\) - $
39+
// CHECK: .*[/\\]NegativeAccuracyTestCase[/\\]main.swift:[[@LINE+3]]: error: NegativeAccuracyTestCase.test_equalWithAccuracy_fails : XCTAssertEqual failed: \("0\.0"\) is not equal to \("0\.2"\) \+\/- \("-0\.1"\) - $
3540
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_fails' failed \(\d+\.\d+ seconds\)
3641
func test_equalWithAccuracy_fails() {
3742
XCTAssertEqual(0, 0.2, accuracy: -0.1)
@@ -40,22 +45,49 @@ class NegativeAccuracyTestCase: XCTestCase {
4045
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_passes' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
4146
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_passes' passed \(\d+\.\d+ seconds\)
4247
func test_notEqualWithAccuracy_passes() {
43-
XCTAssertNotEqual(1, 2, accuracy: -0.5)
48+
XCTAssertNotEqual(1.0, 2.0, accuracy: -0.5)
4449
}
4550

4651
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
4752
// CHECK: .*[/\\]NegativeAccuracyTestCase[/\\]main.swift:[[@LINE+3]]: error: NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails : XCTAssertNotEqual failed: \("1\.0"\) is equal to \("2\.0"\) \+/- \("-1\.0"\) - $
4853
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails' failed \(\d+\.\d+ seconds\)
4954
func test_notEqualWithAccuracy_fails() {
50-
XCTAssertNotEqual(1, 2, accuracy: -1)
55+
XCTAssertNotEqual(1.0, 2.0, accuracy: -1.0)
5156
}
57+
58+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_int_passes' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
59+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_int_passes' passed \(\d+\.\d+ seconds\)
60+
func test_equalWithAccuracy_int_passes() {
61+
XCTAssertEqual(10, 11, accuracy: 1)
62+
}
63+
64+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_int_fails' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
65+
// CHECK: .*[/\\]NegativeAccuracyTestCase[/\\]main.swift:[[@LINE+3]]: error: NegativeAccuracyTestCase.test_equalWithAccuracy_int_fails : XCTAssertEqual failed: \("10"\) is not equal to \("8"\) \+\/- \("1"\) - $
66+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_int_fails' failed \(\d+\.\d+ seconds\)
67+
func test_equalWithAccuracy_int_fails() {
68+
XCTAssertEqual(10, 8, accuracy: 1)
69+
}
70+
71+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_int_passes' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
72+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_int_passes' passed \(\d+\.\d+ seconds\)
73+
func test_notEqualWithAccuracy_int_passes() {
74+
XCTAssertNotEqual(-1, 5, accuracy: 5)
75+
}
76+
77+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_int_fails' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
78+
// CHECK: .*[/\\]NegativeAccuracyTestCase[/\\]main.swift:[[@LINE+3]]: error: NegativeAccuracyTestCase.test_notEqualWithAccuracy_int_fails : XCTAssertNotEqual failed: \("0"\) is equal to \("5"\) \+/- \("5"\) - $
79+
// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_int_fails' failed \(\d+\.\d+ seconds\)
80+
func test_notEqualWithAccuracy_int_fails() {
81+
XCTAssertNotEqual(0, 5, accuracy: 5)
82+
}
83+
5284
}
5385
// CHECK: Test Suite 'NegativeAccuracyTestCase' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
54-
// CHECK: \t Executed 4 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
86+
// CHECK: \t Executed 8 tests, with 4 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
5587

5688
XCTMain([testCase(NegativeAccuracyTestCase.allTests)])
5789

5890
// CHECK: Test Suite '.*\.xctest' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
59-
// CHECK: \t Executed 4 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
91+
// CHECK: \t Executed 8 tests, with 4 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
6092
// CHECK: Test Suite 'All tests' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
61-
// CHECK: \t Executed 4 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
93+
// CHECK: \t Executed 8 tests, with 4 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds

0 commit comments

Comments
 (0)