Skip to content

Commit 102d7f3

Browse files
committed
changed comments in tests
also fixed small logical issue in `Rectangle::new()` where u could create rectangle with width or height equals 0
1 parent c4974ac commit 102d7f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

exercises/tests/tests4.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct Rectangle {
1212
impl Rectangle {
1313
// Only change the test functions themselves
1414
pub fn new(width: i32, height: i32) -> Self {
15-
if width < 0 || height < 0 {
15+
if width <= 0 || height <= 0 {
1616
panic!("Rectangle width and height cannot be negative!")
1717
}
1818
Rectangle {width, height}
@@ -33,13 +33,13 @@ mod tests {
3333

3434
#[test]
3535
fn negative_width() {
36-
// This test should check if thread panics when we try to create rectangle with negative width
36+
// This test should check if program panics when we try to create rectangle with negative width
3737
let _rect = Rectangle::new(-10, 10);
3838
}
3939

4040
#[test]
4141
fn negative_height() {
42-
// This test should check if thread panics when we try to create rectangle with negative height
42+
// This test should check if program panics when we try to create rectangle with negative height
4343
let _rect = Rectangle::new(10, -10);
4444
}
4545
}

0 commit comments

Comments
 (0)