Skip to content

Commit

Permalink
Add proptest for integral function
Browse files Browse the repository at this point in the history
  • Loading branch information
akiradeveloper committed Mar 2, 2024
1 parent 42a44c1 commit 5a82c6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ anyhow = "1"
thiserror = "1"

[dev-dependencies]
proptest = "1.4"
tokio = { version = "1", features = ["full"] }
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,15 @@ mod tests {

Ok(())
}

use proptest::prelude::*;
proptest! {
#![proptest_config(ProptestConfig::with_cases(100000))]
#[test]
fn test_integral(mu: f64, sigma: f64, x: f64) {
let dist = NormalDist { mu, sigma };
let y = dist.integral(x);
assert!(0. <= y && y <= 1.);
}
}
}

0 comments on commit 5a82c6b

Please sign in to comment.