Skip to content

Commit

Permalink
test: add proptest & use for wavelength
Browse files Browse the repository at this point in the history
  • Loading branch information
Walther committed Feb 4, 2024
1 parent 7700896 commit f57b2bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions clovers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tracing = { version = "0.1.40", optional = true }

[dev-dependencies]
divan = "0.1.11"
proptest = "1"

[[bench]]
name = "random"
Expand Down
22 changes: 22 additions & 0 deletions clovers/tests/wavelength.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use clovers::wavelength::*;
use proptest::prelude::*;

proptest! {
#[test]
fn converts_all_wavelengths(lambda in SPECTRUM) {
let _ = wavelength_into_xyz(lambda);
}
}

proptest! {
#[test]
fn rotates_all_wavelengths(lambda in SPECTRUM) {
let mut waves = rotate_wavelength(lambda);
prop_assert_eq!(waves[0], lambda);
waves.sort();
let [a, b, c, d] = waves;
let diff = a.abs_diff(b);
prop_assert_eq!(diff, b.abs_diff(c));
prop_assert_eq!(diff, c.abs_diff(d));
}
}

0 comments on commit f57b2bc

Please sign in to comment.