Skip to content

Commit 1efe9c5

Browse files
committed
Out of comment a zero division
1 parent 28ca7ba commit 1efe9c5

File tree

1 file changed

+9
-4
lines changed
  • chapter8/test_and_documents/src

1 file changed

+9
-4
lines changed

chapter8/test_and_documents/src/main.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ fn math_works() {
1111
assert!(x + 1 == 2);
1212
}
1313

14-
/// panic test
14+
//#[test]
15+
//#[should_panic(expected = "divide by zero")]
16+
//fn divide_by_zero() {
17+
// let y: i32 = 0;
18+
// let _ = 1 / y;
19+
//}
20+
1521
#[test]
1622
#[should_panic(expected = "divide by zero")]
17-
fn divide_by_zero() {
18-
let y = 0;
23+
fn divide_by_zero_negative() {
24+
let y: i32 = -1;
1925
let _ = 1 / y;
2026
}
21-
2227
#[cfg(test)]
2328
mod tests {
2429
fn roughly_equal(a: f64, b: f64) -> bool {

0 commit comments

Comments
 (0)