diff --git a/src/lib.rs b/src/lib.rs index 5c4b068..9f49a40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1467,5 +1467,6 @@ impl PartialEq> for Histogram // TODO: timestamps and tags // TODO: textual output +#[path = "tests/tests.rs"] #[cfg(test)] mod tests; diff --git a/src/tests/helpers.rs b/src/tests/helpers.rs new file mode 100644 index 0000000..88d82f6 --- /dev/null +++ b/src/tests/helpers.rs @@ -0,0 +1,8 @@ +use super::Histogram; + +#[cfg(test)] +pub fn histo64(lowest_discernible_value: u64, highest_trackable_value: u64, num_significant_digits: u8) + -> Histogram { + Histogram::::new_with_bounds(lowest_discernible_value, highest_trackable_value, + num_significant_digits).unwrap() +} diff --git a/src/tests.rs b/src/tests/init.rs similarity index 91% rename from src/tests.rs rename to src/tests/init.rs index 6478463..707d0ab 100644 --- a/src/tests.rs +++ b/src/tests/init.rs @@ -1,4 +1,4 @@ -use super::Histogram; +use tests::helpers::histo64; #[test] fn init_fields_smallest_possible_array() { @@ -250,23 +250,3 @@ fn init_fields_max_value_max_unit_magnitude_max_precision() { assert_eq!(64 - 62 - 1, h.leading_zero_count_base); } - -#[test] -fn new_err_lowest_value_too_large_for_precision() { - let res = Histogram::::new_with_bounds(u64::max_value() / 2, u64::max_value(), 0); - assert_eq!("Cannot represent significant figures' worth of measurements beyond lowest value", - res.unwrap_err()); -} - -#[test] -fn new_err_high_not_double_low() { - let res = Histogram::::new_with_bounds(10, 15, 0); - assert_eq!("highest trackable value must be >= 2 * lowest discernible value", res.unwrap_err()); -} - -#[cfg(test)] -fn histo64(lowest_discernible_value: u64, highest_trackable_value: u64, num_significant_digits: u8) - -> Histogram { - Histogram::::new_with_bounds(lowest_discernible_value, highest_trackable_value, - num_significant_digits).unwrap() -} diff --git a/src/tests/tests.rs b/src/tests/tests.rs new file mode 100644 index 0000000..42038bf --- /dev/null +++ b/src/tests/tests.rs @@ -0,0 +1,12 @@ +use super::Histogram; + +#[path = "helpers.rs"] +mod helpers; +#[path = "init.rs"] +mod init; + +#[test] +fn new_err_high_not_double_low() { + let res = Histogram::::new_with_bounds(10, 15, 0); + assert_eq!("highest trackable value must be >= 2 * lowest discernible value", res.unwrap_err()); +}