From 509be08a52ac2620b2163228f479e60155be452a Mon Sep 17 00:00:00 2001 From: Zerotask <Zerotask@users.noreply.github.com> Date: Sat, 24 Apr 2021 23:15:00 +0200 Subject: [PATCH] chore(tests): update tests3.rs added macros assert_eq!() and assert_ne!() and added a further information link --- exercises/tests/README.md | 1 + exercises/tests/tests3.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/exercises/tests/README.md b/exercises/tests/README.md index 27c6818..0f4e15c 100644 --- a/exercises/tests/README.md +++ b/exercises/tests/README.md @@ -5,3 +5,4 @@ Going out of order from the book to cover tests -- many of the following exercis ## Further information - [Writing Tests](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) +- [Unit testing](https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html) diff --git a/exercises/tests/tests3.rs b/exercises/tests/tests3.rs index 3424f94..ffd3f5f 100644 --- a/exercises/tests/tests3.rs +++ b/exercises/tests/tests3.rs @@ -1,11 +1,11 @@ // tests3.rs // This test isn't testing our function -- make it do that in such a way that -// the test passes. Then write a second test that tests whether we get the result -// we expect to get when we call `is_even(5)`. +// the test passes, but just replace the ??? // Execute `rustlings hint tests3` for hints :) // I AM NOT DONE +// Don't modify this function pub fn is_even(num: i32) -> bool { num % 2 == 0 } @@ -16,11 +16,16 @@ mod tests { #[test] fn is_true_when_even() { - assert!(); + assert!(???); } #[test] fn is_false_when_odd() { - assert!(); + assert_eq!(false, ???); + } + + #[test] + fn is_false_when_odd2() { + assert_ne!(true, ???); } }