Skip to content

Commit 0d59e70

Browse files
committed
Fix test for num_derive
There was a test file, but actually no test in the file! ;)
1 parent 1d02445 commit 0d59e70

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

tests/test_num_derive.rs

+19-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@ use num_derive::{FromPrimitive, Num, NumCast, NumOps, One, ToPrimitive, Zero};
22

33
#[derive(
44
Debug,
5-
Eq,
5+
Clone,
6+
Copy,
67
PartialEq,
8+
Eq,
79
PartialOrd,
810
Ord,
911
FromPrimitive,
1012
ToPrimitive,
11-
One,
1213
Zero,
14+
One,
1315
Num,
1416
NumCast,
1517
NumOps,
1618
)]
1719
struct Weight(i32);
1820

19-
fn main() {
20-
let w1 = Weight(3);
21+
#[test]
22+
fn check_ops() {
23+
let w1 = Weight(7);
2124
let w2 = Weight(4);
22-
println!("{:?}", w1 + w2); // => "Weight(7)"
25+
26+
assert_eq!(w1 + w2, Weight(11));
27+
assert_eq!(w1 - w2, Weight(3));
28+
assert_eq!(w1 * w2, Weight(28));
29+
assert_eq!(w1 / w2, Weight(1));
30+
assert_eq!(w1 % w2, Weight(3));
31+
assert!(w1 > w2);
32+
assert!(w2 < w1);
33+
assert!(w1 >= w1);
34+
assert!(w1 <= w1);
35+
assert!(w1 != w2);
36+
assert!(w1 == w1);
2337
}

0 commit comments

Comments
 (0)