google / google/googletest-rust
Convenient matcher on f32/f64 with error rate
- Dominant language
- Rust
- Stars
- 432
- Forks
- 36
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 2
Description
In [this patch](https://github.com/apache/datasketches-rust/pull/75/files#diff-ca48ad422571f43d769560d89d2df4d4d7c9e831353d679b9c81eaf244d2b894) we have a test case like:
```rust
const RELATIVE_ERROR_FOR_LG_K_11: f64 = 0.02;
const N: usize = 10000;
const N_F64: f64 = N as f64;
assert_that!(
sketch.estimate(),
near(N_F64, RELATIVE_ERROR_FOR_LG_K_11 * N_F64)
);
```
It would be better to have a matcher like `assert_that!(sketch.estimate(), near_(N_F64, RELATIVE_ERROR_FOR_LG_K_11)` that expresses:
```
abs(sketch.estimate() - N_F64) <= N_F64 * RELATIVE_ERROR_FOR_LG_K_11
```
Not sure if there is already good name and implementation in other language's matcher libs.
Contributor guide
Assessment
This issue has not been assessed yet.