diff --git a/clovers/Cargo.toml b/clovers/Cargo.toml index dca5e57b..0097ede0 100644 --- a/clovers/Cargo.toml +++ b/clovers/Cargo.toml @@ -32,6 +32,7 @@ tracing = { version = "0.1.40", optional = true } [dev-dependencies] divan = "0.1.11" +proptest = "1" [[bench]] name = "random" diff --git a/clovers/tests/wavelength.rs b/clovers/tests/wavelength.rs new file mode 100644 index 00000000..533f1639 --- /dev/null +++ b/clovers/tests/wavelength.rs @@ -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)); + } +}