Skip to content

Make XCTAssertEqual with accuracy more generic #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 13, 2020

Conversation

stmontgomery
Copy link
Contributor

Equality with accuracy isn't limited to floating point tests. Sometimes integer (or other numeric types) need to be accurate within certain bounds for the purposes of testing. This change allows any numeric type that has magnitude and distance to be used with XCTAssertEqual(_:_:accuracy:) and XCTAssertNotEqual(_:_:accuracy:).

CC @gormster as the original author of #294 which this PR revives. That PR was automatically closed when the repo changed its default branch to 'main', and I was unable to edit and reopen that PR to the new branch so I opened this new PR to finish landing that change. I rebased those original PR changes, and edited them further to incorporate my own review feedback to remove the Strideable protocol requirement, consolidated some related unit tests and added several more tests.

This now matches the current Xcode 12 behavior, noted in the release notes as bug 58481784.

gormster and others added 3 commits November 23, 2020 18:34
Equality with accuracy isn't limited to floating point tests. Sometimes integer (or other numeric types) need to be accurate within
certain bounds for the purposes of testing. This change allows any numeric type that has magnitude and distance to be used with
`XCTAssertEqual(_:_:accuracy:)` and `XCTAssertNotEqual(_:_: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.
…uality with accuracy" tests, and add more tests
@stmontgomery stmontgomery self-assigned this Nov 24, 2020
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

#endif

// Regression test for https://github.com/apple/swift-corelibs-xctest/pull/7
// and https://github.com/apple/swift-corelibs-xctest/pull/294
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new test source file merges together the two other test files deleted below, incorporating both of their tests and adding several more examples under the "passing" methods.

Copy link
Contributor

@briancroom briancroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for reviving this!

@stmontgomery stmontgomery merged commit 1764c54 into swiftlang:main Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants