-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generalize seeds (see issue #13), minor semver bump
- Loading branch information
1 parent
4a95830
commit 9e4017f
Showing
11 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pub(super) mod math; | ||
pub mod noisebuf; | ||
pub(super) mod ptable; | ||
pub(crate) mod ptable; | ||
#[cfg(feature = "image")] | ||
pub mod visualizer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use libnoise::prelude::*; | ||
use proptest::prelude::*; | ||
|
||
macro_rules! strategy_float_numeric { | ||
() => { | ||
prop::num::f64::NORMAL | ||
| prop::num::f64::NEGATIVE | ||
| prop::num::f64::POSITIVE | ||
| prop::num::f64::ZERO | ||
}; | ||
} | ||
|
||
macro_rules! strategy_array_float_numeric { | ||
() => { | ||
prop::array::uniform(strategy_float_numeric!()) | ||
}; | ||
} | ||
|
||
macro_rules! strategy_byte_array_seed { | ||
() => { | ||
prop::array::uniform32(prop::num::u8::ANY) | ||
}; | ||
} | ||
|
||
proptest! { | ||
// ================================================================= | ||
// test [u8; 32] seeding | ||
// ================================================================= | ||
#[test] | ||
fn test_byte_array_seeding_via_simplex_1d(seed in strategy_byte_array_seed!(), point in strategy_array_float_numeric!()) { | ||
let n = Source::<1>::simplex(seed).sample(point); | ||
prop_assert!((-1.0..=1.0).contains(&n), "value not in [-1, 1] range, instead: {}", n); | ||
} | ||
|
||
#[test] | ||
fn test_byte_array_seeding_via_simplex_2d(seed in strategy_byte_array_seed!(), point in strategy_array_float_numeric!()) { | ||
let n = Source::<2>::simplex(seed).sample(point); | ||
prop_assert!((-1.0..=1.0).contains(&n) || n.is_nan(), "value not in [-1, 1] range, instead: {}", n); | ||
} | ||
|
||
#[test] | ||
fn test_byte_array_seeding_via_simplex_3d(seed in strategy_byte_array_seed!(), point in strategy_array_float_numeric!()) { | ||
let n = Source::<3>::simplex(seed).sample(point); | ||
prop_assert!((-1.0..=1.0).contains(&n) || n.is_nan(), "value not in [-1, 1] range, instead: {}", n); | ||
} | ||
|
||
#[test] | ||
fn test_byte_array_seeding_via_simplex_4d(seed in strategy_byte_array_seed!(), point in strategy_array_float_numeric!()) { | ||
let n = Source::<4>::simplex(seed).sample(point); | ||
prop_assert!((-1.0..=1.0).contains(&n) || n.is_nan(), "value not in [-1, 1] range, instead: {}", n); | ||
} | ||
} |