Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases for ArgminMinMax #391

Merged
merged 17 commits into from
Jan 18, 2024
3 changes: 2 additions & 1 deletion README.md
stefan-k marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
|
<a href="https://github.com/argmin-rs/argmin/tree/argmin-v0.9.0/argmin/examples">Examples (latest release)</a>
|
<a href="https://github.com/argmin-rs/argmin/tree/main/argmin/examples">Examples (main branch)</a>
<a href="https://github.com/argmin-rs/argmin/tree/main/examples">Examples (main branch)</a>
</p>

<p align="center">
Expand Down Expand Up @@ -141,3 +141,4 @@ at your option.
### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
>>>>>>> main
24 changes: 24 additions & 0 deletions argmin-math/src/primitives/minmax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,27 @@ make_minmax!(Complex<isize>);
make_minmax!(Complex<usize>);

// TODO: tests!!!
stefan-k marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(test)]
mod tests {
use super::*;
use paste::item;

macro_rules! make_test {
($t:ty) => {
item! {
#[test]
fn [<test_minmax_ $t>]() {
let x = 5 as $t;
let y = 10 as $t;
assert_eq!(<$t as ArgminMinMax>::min(&x, &y), x);
assert_eq!(<$t as ArgminMinMax>::max(&x, &y), y);
assert_eq!(<$t as ArgminMinMax>::min(&y, &x), x);
assert_eq!(<$t as ArgminMinMax>::max(&y, &x), y);
}
}
}
}

make_test!(f32);
make_test!(f64);
}
Loading