Skip to content
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

Update documentation for the beCloseTo and beWithin matchers #983

Merged
merged 1 commit into from
Apr 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,7 @@ expect([0.0, 2.0]).to(beCloseTo([0.1, 2.1], within: 0.1))

```

> Values given to the `beCloseTo` matcher must be coercable into a
`Double`.
> Values given to the `beCloseTo` matcher must conform to `FloatingPoint`.

## Types/Classes

Expand Down Expand Up @@ -1072,6 +1071,18 @@ expect(turtles).to(containElementSatisfying(^BOOL(id __nonnull object) {
}));
```

For asserting on if the given `Comparable` value is inside of a `Range`, use the `beWithin` matcher.

```swift
// Swift

// Passes if 5 is within the range 1 through 10, inclusive
expect(5).to(beWithin(1...10))

// Passes if 5 is not within the range 2 through 4.
expect(5).toNot(beWithin(2..<5))
```

## Strings

```swift
Expand Down