From 010a04569282149cea7f7a76fc4d7f4c9f0f08dd Mon Sep 17 00:00:00 2001 From: Sanjay K Date: Tue, 19 May 2020 12:47:44 -0400 Subject: feat: renames test to quiz, fixes #244 BREAKING CHANGE * changed test to quiz: fixes issues in #244 * fixed info.toml: #244 * fixed naming related issues --- exercises/quiz1.rs | 23 +++++++++++++++++++++++ exercises/quiz2.rs | 30 ++++++++++++++++++++++++++++++ exercises/quiz3.rs | 29 +++++++++++++++++++++++++++++ exercises/quiz4.rs | 23 +++++++++++++++++++++++ exercises/test1.rs | 23 ----------------------- exercises/test2.rs | 30 ------------------------------ exercises/test3.rs | 29 ----------------------------- exercises/test4.rs | 23 ----------------------- 8 files changed, 105 insertions(+), 105 deletions(-) create mode 100644 exercises/quiz1.rs create mode 100644 exercises/quiz2.rs create mode 100644 exercises/quiz3.rs create mode 100644 exercises/quiz4.rs delete mode 100644 exercises/test1.rs delete mode 100644 exercises/test2.rs delete mode 100644 exercises/test3.rs delete mode 100644 exercises/test4.rs (limited to 'exercises') diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs new file mode 100644 index 0000000..5c5c355 --- /dev/null +++ b/exercises/quiz1.rs @@ -0,0 +1,23 @@ +// quiz1.rs +// This is a quiz for the following sections: +// - Variables +// - Functions + +// Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy +// more than 40 at once, each apple only costs 1! Write a function that calculates +// the price of an order of apples given the order amount. No hints this time! + +// I AM NOT DONE + +// Put your function here! +// fn ..... { + +// Don't modify this function! +#[test] +fn verify_test() { + let price1 = calculate_apple_price(35); + let price2 = calculate_apple_price(65); + + assert_eq!(70, price1); + assert_eq!(65, price2); +} diff --git a/exercises/quiz2.rs b/exercises/quiz2.rs new file mode 100644 index 0000000..8caeaa9 --- /dev/null +++ b/exercises/quiz2.rs @@ -0,0 +1,30 @@ +// quiz2.rs +// This is a quiz for the following sections: +// - Strings + +// Ok, here are a bunch of values-- some are `String`s, some are `&str`s. Your +// task is to call one of these two functions on each value depending on what +// you think each value is. That is, add either `string_slice` or `string` +// before the parentheses on each line. If you're right, it will compile! + +// I AM NOT DONE + +fn string_slice(arg: &str) { + println!("{}", arg); +} +fn string(arg: String) { + println!("{}", arg); +} + +fn main() { + ("blue"); + ("red".to_string()); + (String::from("hi")); + ("rust is fun!".to_owned()); + ("nice weather".into()); + (format!("Interpolation {}", "Station")); + (&String::from("abc")[0..1]); + (" hello there ".trim()); + ("Happy Monday!".to_string().replace("Mon", "Tues")); + ("mY sHiFt KeY iS sTiCkY".to_lowercase()); +} diff --git a/exercises/quiz3.rs b/exercises/quiz3.rs new file mode 100644 index 0000000..30596b9 --- /dev/null +++ b/exercises/quiz3.rs @@ -0,0 +1,29 @@ +// quiz.rs +// This is a quiz for the following sections: +// - Tests + +// This quiz isn't testing our function -- make it do that in such a way that +// 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 :) + +// I AM NOT DONE + +pub fn times_two(num: i32) -> i32 { + num * 2 +} + +#[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)` + } +} diff --git a/exercises/quiz4.rs b/exercises/quiz4.rs new file mode 100644 index 0000000..6c47480 --- /dev/null +++ b/exercises/quiz4.rs @@ -0,0 +1,23 @@ +// quiz4.rs +// This quiz covers the sections: +// - Modules +// - Macros + +// Write a macro that passes the quiz! No hints this time, you can do it! + +// I AM NOT DONE + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_my_macro_world() { + assert_eq!(my_macro!("world!"), "Hello world!"); + } + + #[test] + fn test_my_macro_goodbye() { + assert_eq!(my_macro!("goodbye!"), "Hello goodbye!"); + } +} diff --git a/exercises/test1.rs b/exercises/test1.rs deleted file mode 100644 index 8b5b8fd..0000000 --- a/exercises/test1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// test1.rs -// This is a test for the following sections: -// - Variables -// - Functions - -// Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy -// more than 40 at once, each apple only costs 1! Write a function that calculates -// the price of an order of apples given the order amount. No hints this time! - -// I AM NOT DONE - -// Put your function here! -// fn ..... { - -// Don't modify this function! -#[test] -fn verify_test() { - let price1 = calculate_apple_price(35); - let price2 = calculate_apple_price(65); - - assert_eq!(70, price1); - assert_eq!(65, price2); -} diff --git a/exercises/test2.rs b/exercises/test2.rs deleted file mode 100644 index acdcb95..0000000 --- a/exercises/test2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// test2.rs -// This is a test for the following sections: -// - Strings - -// Ok, here are a bunch of values-- some are `String`s, some are `&str`s. Your -// task is to call one of these two functions on each value depending on what -// you think each value is. That is, add either `string_slice` or `string` -// before the parentheses on each line. If you're right, it will compile! - -// I AM NOT DONE - -fn string_slice(arg: &str) { - println!("{}", arg); -} -fn string(arg: String) { - println!("{}", arg); -} - -fn main() { - ("blue"); - ("red".to_string()); - (String::from("hi")); - ("rust is fun!".to_owned()); - ("nice weather".into()); - (format!("Interpolation {}", "Station")); - (&String::from("abc")[0..1]); - (" hello there ".trim()); - ("Happy Monday!".to_string().replace("Mon", "Tues")); - ("mY sHiFt KeY iS sTiCkY".to_lowercase()); -} diff --git a/exercises/test3.rs b/exercises/test3.rs deleted file mode 100644 index f94c36f..0000000 --- a/exercises/test3.rs +++ /dev/null @@ -1,29 +0,0 @@ -// test3.rs -// This is a test for the following sections: -// - Tests - -// This test isn't testing our function -- make it do that in such a way that -// 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 :) - -// I AM NOT DONE - -pub fn times_two(num: i32) -> i32 { - num * 2 -} - -#[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)` - } -} diff --git a/exercises/test4.rs b/exercises/test4.rs deleted file mode 100644 index ad1f6ac..0000000 --- a/exercises/test4.rs +++ /dev/null @@ -1,23 +0,0 @@ -// test4.rs -// This test covers the sections: -// - Modules -// - Macros - -// Write a macro that passes the test! No hints this time, you can do it! - -// I AM NOT DONE - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_my_macro_world() { - assert_eq!(my_macro!("world!"), "Hello world!"); - } - - #[test] - fn test_my_macro_goodbye() { - assert_eq!(my_macro!("goodbye!"), "Hello goodbye!"); - } -} -- cgit v1.2.3