Skip to content

Commit 286de8c

Browse files
Add documentation for numeric value comparison within specified accuracy #165 (#314)
Add documentation about how to compare two numeric values within specified accuracy. ### Motivation: Issue #165. swift-testing doesn't have an analog of [XCAssertEquals of specified accuracy](https://developer.apple.com/documentation/xctest/3551607-xctassertequal). There is no such function in the standard library. It's unclear to users how they can compare two numeric values. Resolves #165. ### Modifications: Added a comment in the `#expect` macro: should use `isApproximatelyEqual` in the swift-numerics. ### Result: Clearer to users what numeric value comparison is. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 6676949 commit 286de8c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/Testing/Testing.docc/MigratingFromXCTest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ their equivalents in the testing library:
359359
| `try XCTUnwrap(x)` | `try #require(x)` |
360360
| `XCTFail("…")` | `Issue.record("…")` |
361361

362+
The testing library doesn’t provide an equivalent of
363+
[`XCTAssertEqual(_:_:accuracy:_:file:line:)`](https://developer.apple.com/documentation/xctest/3551607-xctassertequal).
364+
To compare two numeric values within a specified accuracy,
365+
use `isApproximatelyEqual()` from [swift-numerics](https://github.com/apple/swift-numerics).
366+
362367
### Continue or halt after test failures
363368

364369
An instance of an `XCTestCase` subclass can set its

0 commit comments

Comments
 (0)