File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed
Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 1- // tests3.rs
2- //
3- // This test isn't testing our function -- make it do that in such a way that
4- // the test passes. Then write a second test that tests whether we get the
5- // result we expect to get when we call `is_even(5)`.
6- //
7- // Execute `rustlings hint tests3` or use the `hint` watch subcommand for a
8- // hint.
9-
10- // I AM NOT DONE
11-
121pub fn is_even ( num : i32 ) -> bool {
132 num % 2 == 0
143}
@@ -19,11 +8,13 @@ mod tests {
198
209 #[ test]
2110 fn is_true_when_even ( ) {
22- assert ! ( ) ;
11+ // 测试偶数:调用is_even(4)应该返回true,assert!验证条件为真
12+ assert ! ( is_even( 4 ) ) ;
2313 }
2414
2515 #[ test]
2616 fn is_false_when_odd ( ) {
27- assert ! ( ) ;
17+ // 测试奇数:调用is_even(5)应该返回false,assert!验证条件为假(加!取反)
18+ assert ! ( !is_even( 5 ) ) ;
2819 }
2920}
You can’t perform that action at this time.
0 commit comments