|
| 1 | +// RUN: %{swiftc} %s -o %{built_tests_dir}/NegativeAccuracyTestCase |
| 2 | +// RUN: %{built_tests_dir}/NegativeAccuracyTestCase > %t || true |
| 3 | +// RUN: %{xctest_checker} %t %s |
| 4 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_passes' started. |
| 5 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_passes' passed \(\d+\.\d+ seconds\). |
| 6 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_fails' started. |
| 7 | +// CHECK: .*/Tests/Functional/NegativeAccuracyTestCase/main.swift:39: error: NegativeAccuracyTestCase.test_equalWithAccuracy_fails : XCTAssertEqualWithAccuracy failed: \(\"0\.0\"\) is not equal to \(\"0\.2\"\) \+\/- \(\"-0\.1\"\) - $ |
| 8 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_equalWithAccuracy_fails' failed \(\d+\.\d+ seconds\). |
| 9 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_passes' started. |
| 10 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_passes' passed \(\d+\.\d+ seconds\). |
| 11 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails' started. |
| 12 | +// CHECK: .*/Tests/Functional/NegativeAccuracyTestCase/main.swift:47: error: NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails : XCTAssertNotEqualWithAccuracy failed: \("1\.0"\) is equal to \("2\.0"\) \+/- \("-1\.0"\) - $ |
| 13 | +// CHECK: Test Case 'NegativeAccuracyTestCase.test_notEqualWithAccuracy_fails' failed \(\d+\.\d+ seconds\). |
| 14 | +// CHECK: Executed 4 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds |
| 15 | +// CHECK: Total executed 4 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds |
| 16 | + |
| 17 | +#if os(Linux) || os(FreeBSD) |
| 18 | + import XCTest |
| 19 | +#else |
| 20 | + import SwiftXCTest |
| 21 | +#endif |
| 22 | + |
| 23 | +// Regression test for https://github.com/apple/swift-corelibs-xctest/pull/7 |
| 24 | +class NegativeAccuracyTestCase: XCTestCase { |
| 25 | + var allTests: [(String, () -> ())] { |
| 26 | + return [ |
| 27 | + ("test_equalWithAccuracy_passes", test_equalWithAccuracy_passes), |
| 28 | + ("test_equalWithAccuracy_fails", test_equalWithAccuracy_fails), |
| 29 | + ("test_notEqualWithAccuracy_passes", test_notEqualWithAccuracy_passes), |
| 30 | + ("test_notEqualWithAccuracy_fails", test_notEqualWithAccuracy_fails), |
| 31 | + ] |
| 32 | + } |
| 33 | + |
| 34 | + func test_equalWithAccuracy_passes() { |
| 35 | + XCTAssertEqualWithAccuracy(0, 0.1, accuracy: -0.1) |
| 36 | + } |
| 37 | + |
| 38 | + func test_equalWithAccuracy_fails() { |
| 39 | + XCTAssertEqualWithAccuracy(0, 0.2, accuracy: -0.1) |
| 40 | + } |
| 41 | + |
| 42 | + func test_notEqualWithAccuracy_passes() { |
| 43 | + XCTAssertNotEqualWithAccuracy(1, 2, -0.5) |
| 44 | + } |
| 45 | + |
| 46 | + func test_notEqualWithAccuracy_fails() { |
| 47 | + XCTAssertNotEqualWithAccuracy(1, 2, -1) |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +XCTMain([NegativeAccuracyTestCase()]) |
0 commit comments