google / google/googletest-rust

Convenient matcher on f32/f64 with error rate

Open
#767 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.