#[macro_use] extern crate proptest;
#[cfg(feature = "timeout")]
mod fib {
use proptest::prelude::*;
fn fib(n: u64) -> u64 {
if n <= 1 {
n
} else {
fib(n - 1) + fib(n - 2)
}
}
proptest! {
#![proptest_config(ProptestConfig {
// Setting both fork and timeout is redundant since timeout implies
// fork, but both are shown for clarity.
fork: true,
timeout: 1000,
.. ProptestConfig::default()
})]
fn test_fib(n in prop::num::u64::ANY) {
assert!(fib(n) >= n);
}
}
pub fn do_test_fib() {
test_fib();
}
}
fn main() {
#[cfg(feature = "timeout")]
fib::do_test_fib();
}