From 3db6c0baf4696dfd3c3282cbfba685a7334eb167 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron R." Date: Wed, 3 Jul 2024 00:06:56 -0600 Subject: [PATCH] tests done --- exercises/tests/tests1.rs | 3 +-- exercises/tests/tests2.rs | 3 +-- exercises/tests/tests3.rs | 5 ++--- exercises/tests/tests4.rs | 7 ++++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/exercises/tests/tests1.rs b/exercises/tests/tests1.rs index 810277a..a4808c5 100644 --- a/exercises/tests/tests1.rs +++ b/exercises/tests/tests1.rs @@ -10,12 +10,11 @@ // Execute `rustlings hint tests1` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE #[cfg(test)] mod tests { #[test] fn you_can_assert() { - assert!(); + assert!(true); } } diff --git a/exercises/tests/tests2.rs b/exercises/tests/tests2.rs index f8024e9..d93ea05 100644 --- a/exercises/tests/tests2.rs +++ b/exercises/tests/tests2.rs @@ -6,12 +6,11 @@ // Execute `rustlings hint tests2` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE #[cfg(test)] mod tests { #[test] fn you_can_assert_eq() { - assert_eq!(); + assert_eq!(1,1); } } diff --git a/exercises/tests/tests3.rs b/exercises/tests/tests3.rs index 4013e38..50b849b 100644 --- a/exercises/tests/tests3.rs +++ b/exercises/tests/tests3.rs @@ -7,7 +7,6 @@ // Execute `rustlings hint tests3` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE pub fn is_even(num: i32) -> bool { num % 2 == 0 @@ -19,11 +18,11 @@ mod tests { #[test] fn is_true_when_even() { - assert!(); + assert!(is_even(2)); } #[test] fn is_false_when_odd() { - assert!(); + assert!(!is_even(5)); } } diff --git a/exercises/tests/tests4.rs b/exercises/tests/tests4.rs index 935d0db..7c11a59 100644 --- a/exercises/tests/tests4.rs +++ b/exercises/tests/tests4.rs @@ -5,7 +5,6 @@ // Execute `rustlings hint tests4` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE struct Rectangle { width: i32, @@ -30,17 +29,19 @@ mod tests { fn correct_width_and_height() { // This test should check if the rectangle is the size that we pass into its constructor let rect = Rectangle::new(10, 20); - assert_eq!(???, 10); // check width - assert_eq!(???, 20); // check height + assert_eq!(rect.width, 10); // check width + assert_eq!(rect.height, 20); // check height } #[test] + #[should_panic] fn negative_width() { // This test should check if program panics when we try to create rectangle with negative width let _rect = Rectangle::new(-10, 10); } #[test] + #[should_panic] fn negative_height() { // This test should check if program panics when we try to create rectangle with negative height let _rect = Rectangle::new(10, -10);