From a3b8ccd3a80c1b95accae2343fe2619e4f288793 Mon Sep 17 00:00:00 2001 From: MSilva95 Date: Tue, 29 Dec 2020 18:21:00 +0000 Subject: [PATCH] fix --- rust/tests/adding_twice_test/src/main.rs | 2 - rust/tests/diamond_creation_test/src/main.rs | 16 +++--- .../division_and_remainder_test/Cargo.toml | 4 +- rust/tests/get_products_test/Cargo.lock | 7 +++ rust/tests/get_products_test/Cargo.toml | 2 +- rust/tests/highest_test/src/main.rs | 9 +--- rust/tests/iterators_test/src/main.rs | 10 +--- rust/tests/reverse_string_test/Cargo.toml | 2 +- rust/tests/rgb_match_test/src/main.rs | 8 --- rust/tests/rot_test/src/main.rs | 54 +++++++++---------- rust/tests/scores_test/Cargo.lock | 9 +++- subjects/rot/README.md | 26 ++++----- 12 files changed, 71 insertions(+), 78 deletions(-) diff --git a/rust/tests/adding_twice_test/src/main.rs b/rust/tests/adding_twice_test/src/main.rs index 7c980b806..e6febb292 100644 --- a/rust/tests/adding_twice_test/src/main.rs +++ b/rust/tests/adding_twice_test/src/main.rs @@ -31,8 +31,6 @@ fn main() { let value = twice(neg); println!("{}", value(7)); } -fn twice (fun: impl Fn() -> ) -> Fn() -> { -} #[cfg(test)] mod tests { diff --git a/rust/tests/diamond_creation_test/src/main.rs b/rust/tests/diamond_creation_test/src/main.rs index 702cc1fc3..35b293d60 100644 --- a/rust/tests/diamond_creation_test/src/main.rs +++ b/rust/tests/diamond_creation_test/src/main.rs @@ -3,7 +3,7 @@ ### Instructions -Complete the function "make_diamond" that takes a letter as input, and outputs it in a diamond shape. +Complete the function "get_diamond" that takes a letter as input, and outputs it in a diamond shape. Rules: @@ -53,8 +53,8 @@ E·······E */ use diamond_creation::*; fn main() { - println!("{:?}", make_diamond('A')); - println!("{:?}", make_diamond('C')); + println!("{:?}", get_diamond('A')); + println!("{:?}", get_diamond('C')); } #[cfg(test)] @@ -63,18 +63,18 @@ mod test { #[test] fn test_a() { - assert_eq!(make_diamond('A'), vec!["A"]); + assert_eq!(get_diamond('A'), vec!["A"]); } #[test] fn test_b() { - assert_eq!(make_diamond('B'), vec![" A ", "B B", " A "]); + assert_eq!(get_diamond('B'), vec![" A ", "B B", " A "]); } #[test] fn test_c() { assert_eq!( - make_diamond('C'), + get_diamond('C'), vec![" A ", " B B ", "C C", " B B ", " A "] ); } @@ -82,7 +82,7 @@ mod test { #[test] fn test_d() { assert_eq!( - make_diamond('D'), + get_diamond('D'), vec![" A ", " B B ", " C C ", "D D", " C C ", " B B ", " A ",] ); } @@ -90,7 +90,7 @@ mod test { #[test] fn test_z() { assert_eq!( - make_diamond('Z'), + get_diamond('Z'), vec![ " A ", " B B ", diff --git a/rust/tests/division_and_remainder_test/Cargo.toml b/rust/tests/division_and_remainder_test/Cargo.toml index a01bb2d0e..8785f0c81 100644 --- a/rust/tests/division_and_remainder_test/Cargo.toml +++ b/rust/tests/division_and_remainder_test/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "division_and_reminder_test" +name = "division_and_remainder_test" version = "0.1.0" authors = ["Augusto "] edition = "2018" @@ -7,4 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -division_and_remainder = { path = "../../../../rust-piscine-solutions/division_and_remainder" } +division_and_remainder= { path = "../../../../rust-piscine-solutions/division_and_remainder" } diff --git a/rust/tests/get_products_test/Cargo.lock b/rust/tests/get_products_test/Cargo.lock index d8511c7a5..d26d0b667 100644 --- a/rust/tests/get_products_test/Cargo.lock +++ b/rust/tests/get_products_test/Cargo.lock @@ -3,3 +3,10 @@ [[package]] name = "get_products" version = "0.1.0" + +[[package]] +name = "get_products_test" +version = "0.1.0" +dependencies = [ + "get_products", +] diff --git a/rust/tests/get_products_test/Cargo.toml b/rust/tests/get_products_test/Cargo.toml index b40fbeb01..b847ada0f 100644 --- a/rust/tests/get_products_test/Cargo.toml +++ b/rust/tests/get_products_test/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -get_products = { path = "../../../../rust-piscine-solutions/ge"} +get_products = { path = "../../../../rust-piscine-solutions/get_products"} diff --git a/rust/tests/highest_test/src/main.rs b/rust/tests/highest_test/src/main.rs index e9614fdd5..45ab3cfd5 100644 --- a/rust/tests/highest_test/src/main.rs +++ b/rust/tests/highest_test/src/main.rs @@ -17,11 +17,6 @@ */ use highest::*; -#[derive(Debug)] -struct Numbers<'a> { - numbers: &'a [u32], -} - fn main() { let expected = [30, 500, 20, 70]; let n = Numbers::new(&expected); @@ -48,7 +43,7 @@ mod tests { let n = Numbers::new(&[100, 0, 90, 30]); let f = Numbers::new(&[]); assert_eq!(n.Latest(), Some(30)); - assert!(f.Latest().is_none(), "It should have been None, {}", f.Latest()); + assert!(f.Latest().is_none(), "It should have been None, {:?}", f.Latest()); } #[test] @@ -56,7 +51,7 @@ mod tests { let n = Numbers::new(&[40, 100, 70]); let f = Numbers::new(&[]); assert_eq!(n.Highest(), Some(100)); - assert!(f.Highest().is_none(), "It should have been None, {}", f.Highest()); + assert!(f.Highest().is_none(), "It should have been None, {:?}", f.Highest()); } #[test] diff --git a/rust/tests/iterators_test/src/main.rs b/rust/tests/iterators_test/src/main.rs index 7508d9d47..9983ca5b1 100644 --- a/rust/tests/iterators_test/src/main.rs +++ b/rust/tests/iterators_test/src/main.rs @@ -1,5 +1,5 @@ /* -## even_iterator +## iterators ### Instructions @@ -26,19 +26,13 @@ fn main() { println!("{:?}", a.next()); // Some((6, 5, 120)) println!("{:?}", a.next()); // Some((8, 7, 720)) println!("{:?}", a.next()); // Some((10, 9, 5040)) - println!() + println!(); let mut a = Number::new(18); println!("{:?}", a.next()); // Some((18, 19, 6402373705728000)) println!("{:?}", a.next()); // Some((20, 21, 121645100408832000)) println!("{:?}", a.next()); // Some((22, 23, 2432902008176640000)) } -struct Number { - even: usize, - odd: usize, - fact: usize, -} - #[cfg(test)] mod tests { use super::*; diff --git a/rust/tests/reverse_string_test/Cargo.toml b/rust/tests/reverse_string_test/Cargo.toml index 3b6160797..5ea26d980 100644 --- a/rust/tests/reverse_string_test/Cargo.toml +++ b/rust/tests/reverse_string_test/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "reverse-string_test" +name = "reverse_string_test" version = "0.1.0" authors = ["MSilva95 "] edition = "2018" diff --git a/rust/tests/rgb_match_test/src/main.rs b/rust/tests/rgb_match_test/src/main.rs index 8eaef5b5a..5d9e58f30 100644 --- a/rust/tests/rgb_match_test/src/main.rs +++ b/rust/tests/rgb_match_test/src/main.rs @@ -13,14 +13,6 @@ you want to `swap(c.a, c.g)` you will get -> Color { r: 255, g: 30, b: 10, a: 20 */ use rgb_match::*; -#[derive(Debug, Clone, Copy, PartialEq)] -struct Color { - r: u8, - g: u8, - b: u8, - a: u8, -} - fn main() { let c = Color { r: 255, diff --git a/rust/tests/rot_test/src/main.rs b/rust/tests/rot_test/src/main.rs index ac0d498e8..445a44412 100644 --- a/rust/tests/rot_test/src/main.rs +++ b/rust/tests/rot_test/src/main.rs @@ -1,5 +1,5 @@ /* - ## rot + ## rotate ### Instructions @@ -11,8 +11,8 @@ A ROT13 on the Latin alphabet would be as follows: - Cipher: nopqrstuvwxyzabcdefghijklm -Your purpose in this exercise is to create a similar `rot` function that is a better version of the ROT13 cipher. -Your function will receive a string and a number and it will rot each letter of that string, the number of times, settled by the second argument, to the right or to the left if the number are negative. +Your purpose in this exercise is to create a similar `rotate` function that is a better version of the ROT13 cipher. +Your function will receive a string and a number and it will rotate each letter of that string, the number of times, settled by the second argument, to the right or to the left if the number are negative. Your function should only change letters. If the string includes punctuation and numbers they will remain the same. @@ -35,25 +35,25 @@ use rot::*; fn main() { - println!("The letter \"a\" becomes: {}", rot("a", 26)); - println!("The letter \"m\" becomes: {}", rot("m", 0)); - println!("The letter \"m\" becomes: {}", rot("m", 13)); - println!("The letter \"a\" becomes: {}", rot("a", 15)); - println!("The word \"MISS\" becomes: {}", rot("MISS", 5)); + println!("The letter \"a\" becomes: {}", rotate("a", 26)); + println!("The letter \"m\" becomes: {}", rotate("m", 0)); + println!("The letter \"m\" becomes: {}", rotate("m", 13)); + println!("The letter \"a\" becomes: {}", rotate("a", 15)); + println!("The word \"MISS\" becomes: {}", rotate("MISS", 5)); println!( "The decoded message is: {}", - rot("Gur svir obkvat jvmneqf whzc dhvpxyl.", 13) + rotate("Gur svir obkvat jvmneqf whzc dhvpxyl.", 13) ); println!( "The decoded message is: {}", - rot("Mtb vznhpqd ifky ozrunsl ejgwfx ajc", 5) + rotate("Mtb vznhpqd ifky ozrunsl ejgwfx ajc", 5) ); println!( "Your cypher wil be: {}", - rot("Testing with numbers 1 2 3", 4) + rotate("Testing with numbers 1 2 3", 4) ); - println!("Your cypher wil be: {}", rot("Testing", -14)); - println!("The letter \"a\" becomes: {}", rot("a", -1)); + println!("Your cypher wil be: {}", rotate("Testing", -14)); + println!("The letter \"a\" becomes: {}", rotate("a", -1)); } #[cfg(test)] @@ -62,21 +62,21 @@ mod test { #[test] fn test_simple() { - assert_eq!("z", rot("m", 13)); - assert_eq!("n", rot("m", 1)); - assert_eq!("a", rot("a", 26)); - assert_eq!("z", rot("a", 25)); - assert_eq!("b", rot("l", 16)); - assert_eq!("j", rot("j", 0)); - assert_eq!("RNXX", rot("MISS", 5)); - assert_eq!("M J Q Q T", rot("H E L L O", 5)); + assert_eq!("z", rotate("m", 13)); + assert_eq!("n", rotate("m", 1)); + assert_eq!("a", rotate("a", 26)); + assert_eq!("z", rotate("a", 25)); + assert_eq!("b", rotate("l", 16)); + assert_eq!("j", rotate("j", 0)); + assert_eq!("RNXX", rotate("MISS", 5)); + assert_eq!("M J Q Q T", rotate("H E L L O", 5)); } #[test] fn test_all_letters() { assert_eq!( "Gur svir obkvat jvmneqf whzc dhvpxyl.", - rot("The five boxing wizards jump quickly.", 13) + rotate("The five boxing wizards jump quickly.", 13) ); } @@ -84,15 +84,15 @@ mod test { fn test_numbers_punctuation() { assert_eq!( "Xiwxmrk amxl ryqfivw 1 2 3", - rot("Testing with numbers 1 2 3", 4) + rotate("Testing with numbers 1 2 3", 4) ); - assert_eq!("Gzo\'n zvo, Bmviyhv!", rot("Let\'s eat, Grandma!", 21)); + assert_eq!("Gzo\'n zvo, Bmviyhv!", rotate("Let\'s eat, Grandma!", 21)); } #[test] fn test_negative() { - assert_eq!("z", rot("a", -1)); - assert_eq!("W", rot("A", -4)); - assert_eq!("Fqefuzs", rot("Testing", -14)); + assert_eq!("z", rotate("a", -1)); + assert_eq!("W", rotate("A", -4)); + assert_eq!("Fqefuzs", rotate("Testing", -14)); } } diff --git a/rust/tests/scores_test/Cargo.lock b/rust/tests/scores_test/Cargo.lock index ac25b3965..8455d4bd6 100644 --- a/rust/tests/scores_test/Cargo.lock +++ b/rust/tests/scores_test/Cargo.lock @@ -1,6 +1,13 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "scrabble" +name = "scores" version = "0.1.0" +[[package]] +name = "scores_test" +version = "0.1.0" +dependencies = [ + "scores 0.1.0", +] + diff --git a/subjects/rot/README.md b/subjects/rot/README.md index 7f544344c..01c8b075a 100644 --- a/subjects/rot/README.md +++ b/subjects/rot/README.md @@ -1,4 +1,4 @@ -## rot +## rotate ### Instructions @@ -10,7 +10,7 @@ A ROT13 on the Latin alphabet would be as follows: - Cipher: nopqrstuvwxyzabcdefghijklm -Your purpose in this exercise is to create a similar `rot` function that is a better version of the ROT13 cipher. +Your purpose in this exercise is to create a similar `rotate` function that is a better version of the ROT13 cipher. Your function will receive a string and a number and it will rotate each letter of that string the number of times settled by the second argument to the right, or to the left if the number are negative. @@ -24,7 +24,7 @@ they will remain the same. ### Expected functions ```rust -pub fn rot(input: &str, key: i8) -> String {} +pub fn rotate(input: &str, key: i8) -> String {} ``` ### Usage @@ -36,25 +36,25 @@ use rot::rot; fn main() { - println!("The letter \"a\" becomes: {}", rot("a", 26)); - println!("The letter \"m\" becomes: {}", rot("m", 0)); - println!("The letter \"m\" becomes: {}", rot("m", 13)); - println!("The letter \"a\" becomes: {}", rot("a", 15)); - println!("The word \"MISS\" becomes: {}", rot("MISS", 5)); + println!("The letter \"a\" becomes: {}", rotate("a", 26)); + println!("The letter \"m\" becomes: {}", rotate("m", 0)); + println!("The letter \"m\" becomes: {}", rotate("m", 13)); + println!("The letter \"a\" becomes: {}", rotate("a", 15)); + println!("The word \"MISS\" becomes: {}", rotate("MISS", 5)); println!( "The decoded message is: {}", - rot("Gur svir obkvat jvmneqf whzc dhvpxyl.", 13) + rotate("Gur svir obkvat jvmneqf whzc dhvpxyl.", 13) ); println!( "The decoded message is: {}", - rot("Mtb vznhpqd ifky ozrunsl ejgwfx ajc", 5) + rotate("Mtb vznhpqd ifky ozrunsl ejgwfx ajc", 5) ); println!( "Your cypher wil be: {}", - rot("Testing with numbers 1 2 3", 4) + rotate("Testing with numbers 1 2 3", 4) ); - println!("Your cypher wil be: {}", rot("Testing", -14)); - println!("The letter \"a\" becomes: {}", rot("a", -1)); + println!("Your cypher wil be: {}", rotate("Testing", -14)); + println!("The letter \"a\" becomes: {}", rotate("a", -1)); } ```