2020-05-19 17:47:44 +01:00
|
|
|
// quiz.rs
|
|
|
|
// This is a quiz for the following sections:
|
2019-11-11 12:46:42 +00:00
|
|
|
// - Tests
|
2019-01-23 19:48:01 +00:00
|
|
|
|
2020-05-19 17:47:44 +01:00
|
|
|
// This quiz isn't testing our function -- make it do that in such a way that
|
2019-11-11 12:46:42 +00:00
|
|
|
// the test passes. Then write a second test that tests that we get the result
|
|
|
|
// we expect to get when we call `times_two` with a negative number.
|
|
|
|
// No hints, you can do this :)
|
2015-09-20 23:03:00 +01:00
|
|
|
|
2019-11-11 12:38:24 +00:00
|
|
|
// I AM NOT DONE
|
|
|
|
|
2019-11-11 12:46:42 +00:00
|
|
|
pub fn times_two(num: i32) -> i32 {
|
|
|
|
num * 2
|
2019-06-07 03:52:42 +01:00
|
|
|
}
|
2015-09-20 23:03:00 +01:00
|
|
|
|
2019-11-11 12:46:42 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn returns_twice_of_positive_numbers() {
|
|
|
|
assert_eq!(times_two(4), ???);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn returns_twice_of_negative_numbers() {
|
|
|
|
// TODO write an assert for `times_two(-4)`
|
|
|
|
}
|
2015-09-20 23:03:00 +01:00
|
|
|
}
|