Skip to content

Commit 33f18a7

Browse files
committed
Add tests
Test a function of: boolean op, unary op, binary op, binary op with arrays
1 parent a947d82 commit 33f18a7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/numeric.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,40 @@ fn diff_panic_axis_out_of_bounds()
476476
let data = array![1, 2, 4, 7];
477477
data.diff(1, Axis(2));
478478
}
479+
480+
#[test]
481+
#[cfg(feature = "std")]
482+
fn test_boolean_op_is_nan()
483+
{
484+
let data = array![1.0, 2.0, 4.0, 7.0, f64::NAN];
485+
let expected = array![false, false, false, false, true];
486+
assert_eq!(data.is_nan(), expected);
487+
}
488+
489+
#[test]
490+
#[cfg(feature = "std")]
491+
fn test_unary_op_round()
492+
{
493+
let data = array![0.0, 0.1, 0.5, 0.9, 1.0, 1.5];
494+
let expected = array![0.0, 0.0, 1.0, 1.0, 1.0, 2.0];
495+
assert_eq!(data.round(), expected);
496+
}
497+
498+
#[test]
499+
#[cfg(feature = "std")]
500+
fn test_binary_op_powi()
501+
{
502+
let data = array![1.0, 2.0, 4.0, 7.0];
503+
let expected = array![1.0, 8.0, 64.0, 343.0];
504+
assert_eq!(data.powi(3), expected);
505+
}
506+
507+
#[test]
508+
#[cfg(feature = "std")]
509+
fn test_binary_op_hypot_all()
510+
{
511+
let a = array![[3.0, 5.0], [8.0, 7.0]];
512+
let b = array![[4.0, 12.0], [15.0, 24.0]];
513+
let expected = array![[5.0, 13.0], [17.0, 25.0]];
514+
assert_eq!(a.hypot_all(&b), expected);
515+
}

0 commit comments

Comments
 (0)