summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorponeciak <poneciak@gmail.com>2023-04-05 13:24:14 +0200
committerponeciak <poneciak@gmail.com>2023-04-05 13:24:14 +0200
commit102d7f3d0ec8d9e6b0f4380c9ec199c47cf127f1 (patch)
treea1a2d17a6e71b30b344d8fc94a89f4d1e59d28f5 /exercises
parentc4974ac7820784899592a26b4227683bca96bd2b (diff)
changed comments in tests
also fixed small logical issue in `Rectangle::new()` where u could create rectangle with width or height equals 0
Diffstat (limited to 'exercises')
-rw-r--r--exercises/tests/tests4.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/exercises/tests/tests4.rs b/exercises/tests/tests4.rs
index 727dbd7..1f34a2b 100644
--- a/exercises/tests/tests4.rs
+++ b/exercises/tests/tests4.rs
@@ -12,7 +12,7 @@ struct Rectangle {
impl Rectangle {
// Only change the test functions themselves
pub fn new(width: i32, height: i32) -> Self {
- if width < 0 || height < 0 {
+ if width <= 0 || height <= 0 {
panic!("Rectangle width and height cannot be negative!")
}
Rectangle {width, height}
@@ -33,13 +33,13 @@ mod tests {
#[test]
fn negative_width() {
- // This test should check if thread panics when we try to create rectangle with 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]
fn negative_height() {
- // This test should check if thread panics when we try to create rectangle with negative height
+ // This test should check if program panics when we try to create rectangle with negative height
let _rect = Rectangle::new(10, -10);
}
}