Skip to content

Commit

Permalink
Refactor macro tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Apr 26, 2024
1 parent ca4859e commit 256932f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 17 additions & 1 deletion tests/integration/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use average::{concatenate, Estimate, Max, Min};

concatenate!(pub MinMax, [Min, min], [Max, max]);
concatenate!(MinMax, [Min, min], [Max, max]);

#[test]
fn concatenate_simple() {
Expand Down Expand Up @@ -68,3 +68,19 @@ fn concatenate_moments_quantile() {
assert_eq!(e.sample_variance(), 2.5);
assert_eq!(e.quantile(), 3.0);
}

#[test]
fn concatenate_pub() {
mod submodule {
use average::{concatenate, Min, Max, Estimate};
concatenate!(pub MinMax, [Min, min], [Max, max]);
}

let mut s = submodule::MinMax::new();
for i in 1..6 {
s.add(f64::from(i));
}

assert_eq!(s.min(), 1.0);
assert_eq!(s.max(), 5.0);
}
4 changes: 0 additions & 4 deletions tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ mod skewness;
mod streaming_stats;
mod weighted_mean;
mod covariance;

// Ensure that the struct defined by macro is accessible
#[allow(unused_imports)]
use macros::MinMax;

0 comments on commit 256932f

Please sign in to comment.