Skip to content

Commit

Permalink
Implemented tests directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirk True committed Apr 14, 2020
1 parent 02d8874 commit 0189328
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
6 changes: 2 additions & 4 deletions exercises/test3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// we expect to get when we call `times_two` with a negative number.
// No hints, you can do this :)

// I AM NOT DONE

pub fn times_two(num: i32) -> i32 {
num * 2
}
Expand All @@ -19,11 +17,11 @@ mod tests {

#[test]
fn returns_twice_of_positive_numbers() {
assert_eq!(times_two(4), ???);
assert_eq!(times_two(4), 8);
}

#[test]
fn returns_twice_of_negative_numbers() {
// TODO write an assert for `times_two(-4)`
assert_eq!(times_two(-4), -8)
}
}
4 changes: 1 addition & 3 deletions exercises/tests/tests1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
// This test has a problem with it -- make the test compile! Make the test
// pass! Make the test fail! Execute `rustlings hint tests1` for hints :)

// I AM NOT DONE

#[cfg(test)]
mod tests {
#[test]
fn you_can_assert() {
assert!();
assert!(true);
}
}
4 changes: 1 addition & 3 deletions exercises/tests/tests2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// This test has a problem with it -- make the test compile! Make the test
// pass! Make the test fail! Execute `rustlings hint tests2` for hints :)

// I AM NOT DONE

#[cfg(test)]
mod tests {
#[test]
fn you_can_assert_eq() {
assert_eq!();
assert_eq!(1, 1);
}
}
4 changes: 1 addition & 3 deletions exercises/tests/tests3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// we expect to get when we call `is_even(5)`.
// Execute `rustlings hint tests3` for hints :)

// I AM NOT DONE

pub fn is_even(num: i32) -> bool {
num % 2 == 0
}
Expand All @@ -16,6 +14,6 @@ mod tests {

#[test]
fn is_true_when_even() {
assert!();
assert!(is_even(32));
}
}

0 comments on commit 0189328

Please sign in to comment.