diff --git a/exercises/practice/bob/.meta/test_template.tera b/exercises/practice/bob/.meta/test_template.tera new file mode 100644 index 000000000..dd7557012 --- /dev/null +++ b/exercises/practice/bob/.meta/test_template.tera @@ -0,0 +1,9 @@ +use bob::*; + +{% for test in cases %} +#[test] +#[ignore] +fn {{ test.description | snake_case }}() { + assert_eq!(reply({{ test.input.heyBob | json_encode() }}), "{{ test.expected }}"); +} +{% endfor -%} diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index f357dccdb..ea47d6bb0 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -1,9 +1,85 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[e162fead-606f-437a-a166-d051915cea8e] +description = "stating something" [73a966dc-8017-47d6-bb32-cf07d1a5fcd9] description = "shouting" +[d6c98afd-df35-4806-b55e-2c457c3ab748] +description = "shouting gibberish" + +[8a2e771d-d6f1-4e3f-b6c6-b41495556e37] +description = "asking a question" + +[81080c62-4e4d-4066-b30a-48d8d76920d9] +description = "asking a numeric question" + +[2a02716d-685b-4e2e-a804-2adaf281c01e] +description = "asking gibberish" + +[c02f9179-ab16-4aa7-a8dc-940145c385f7] +description = "talking forcefully" + +[153c0e25-9bb5-4ec5-966e-598463658bcd] +description = "using acronyms in regular speech" + +[a5193c61-4a92-4f68-93e2-f554eb385ec6] +description = "forceful question" + +[a20e0c54-2224-4dde-8b10-bd2cdd4f61bc] +description = "shouting numbers" + +[f7bc4b92-bdff-421e-a238-ae97f230ccac] +description = "no letters" + +[bb0011c5-cd52-4a5b-8bfb-a87b6283b0e2] +description = "question with no letters" + +[496143c8-1c31-4c01-8a08-88427af85c66] +description = "shouting with special characters" + +[e6793c1c-43bd-4b8d-bc11-499aea73925f] +description = "shouting with no exclamation mark" + +[aa8097cc-c548-4951-8856-14a404dd236a] +description = "statement containing question mark" + +[9bfc677d-ea3a-45f2-be44-35bc8fa3753e] +description = "non-letters with question" + +[8608c508-f7de-4b17-985b-811878b3cf45] +description = "prattling on" + [bc39f7c6-f543-41be-9a43-fd1c2f753fc0] description = "silence" + +[d6c47565-372b-4b09-b1dd-c40552b8378b] +description = "prolonged silence" + +[4428f28d-4100-4d85-a902-e5a78cb0ecd3] +description = "alternate silence" + +[66953780-165b-4e7e-8ce3-4bcb80b6385a] +description = "multiple line question" + +[5371ef75-d9ea-4103-bcfa-2da973ddec1b] +description = "starting with whitespace" + +[05b304d6-f83b-46e7-81e0-4cd3ca647900] +description = "ending with whitespace" + +[72bd5ad3-9b2f-4931-a988-dce1f5771de2] +description = "other whitespace" + +[12983553-8601-46a8-92fa-fcaa3bc4a2a0] +description = "non-question ending with whitespace" diff --git a/exercises/practice/bob/tests/bob.rs b/exercises/practice/bob/tests/bob.rs index fdee5588f..4fa71681c 100644 --- a/exercises/practice/bob/tests/bob.rs +++ b/exercises/practice/bob/tests/bob.rs @@ -1,190 +1,168 @@ -fn process_response_case(phrase: &str, expected_response: &str) { - assert_eq!(bob::reply(phrase), expected_response); -} +use bob::*; #[test] -/// stating something fn stating_something() { - process_response_case("Tom-ay-to, tom-aaaah-to.", "Whatever."); + assert_eq!(reply("Tom-ay-to, tom-aaaah-to."), "Whatever."); } #[test] #[ignore] -/// ending with whitespace -fn ending_with_whitespace() { - process_response_case("Okay if like my spacebar quite a bit? ", "Sure."); +fn shouting() { + assert_eq!(reply("WATCH OUT!"), "Whoa, chill out!"); } #[test] #[ignore] -/// shouting numbers -fn shouting_numbers() { - process_response_case("1, 2, 3 GO!", "Whoa, chill out!"); +fn shouting_gibberish() { + assert_eq!(reply("FCECDFCAAB"), "Whoa, chill out!"); } #[test] #[ignore] -/// other whitespace -fn other_whitespace() { - process_response_case("\r\r ", "Fine. Be that way!"); +fn asking_a_question() { + assert_eq!( + reply("Does this cryogenic chamber make me look fat?"), + "Sure." + ); } #[test] #[ignore] -/// shouting with special characters -fn shouting_with_special_characters() { - process_response_case( - "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!", - "Whoa, chill out!", - ); +fn asking_a_numeric_question() { + assert_eq!(reply("You are, what, like 15?"), "Sure."); } #[test] #[ignore] -/// talking forcefully -fn talking_forcefully() { - process_response_case("Hi there!", "Whatever."); +fn asking_gibberish() { + assert_eq!(reply("fffbbcbeab?"), "Sure."); } #[test] #[ignore] -/// prattling on -fn prattling_on() { - process_response_case("Wait! Hang on. Are you going to be OK?", "Sure."); +fn talking_forcefully() { + assert_eq!(reply("Hi there!"), "Whatever."); } #[test] #[ignore] -/// forceful question -fn forceful_question() { - process_response_case("WHAT'S GOING ON?", "Calm down, I know what I'm doing!"); +fn using_acronyms_in_regular_speech() { + assert_eq!( + reply("It's OK if you don't want to go work for NASA."), + "Whatever." + ); } #[test] #[ignore] -/// shouting with no exclamation mark -fn shouting_with_no_exclamation_mark() { - process_response_case("I HATE THE DENTIST", "Whoa, chill out!"); +fn forceful_question() { + assert_eq!( + reply("WHAT'S GOING ON?"), + "Calm down, I know what I'm doing!" + ); } #[test] #[ignore] -/// asking gibberish -fn asking_gibberish() { - process_response_case("fffbbcbeab?", "Sure."); +fn shouting_numbers() { + assert_eq!(reply("1, 2, 3 GO!"), "Whoa, chill out!"); } #[test] #[ignore] -/// question with no letters -fn question_with_no_letters() { - process_response_case("4?", "Sure."); +fn no_letters() { + assert_eq!(reply("1, 2, 3"), "Whatever."); } #[test] #[ignore] -/// no letters -fn no_letters() { - process_response_case("1, 2, 3", "Whatever."); +fn question_with_no_letters() { + assert_eq!(reply("4?"), "Sure."); } #[test] #[ignore] -/// statement containing question mark -fn statement_containing_question_mark() { - process_response_case("Ending with ? means a question.", "Whatever."); +fn shouting_with_special_characters() { + assert_eq!( + reply("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"), + "Whoa, chill out!" + ); } -//NEW #[test] #[ignore] -/// multiple line question -fn multiple_line_question() { - process_response_case( - "\rDoes this cryogenic chamber make me look fat?\rNo.", - "Whatever.", - ); +fn shouting_with_no_exclamation_mark() { + assert_eq!(reply("I HATE THE DENTIST"), "Whoa, chill out!"); } #[test] #[ignore] -/// non-question ending with whitespace -fn nonquestion_ending_with_whitespace() { - process_response_case( - "This is a statement ending with whitespace ", - "Whatever.", - ); +fn statement_containing_question_mark() { + assert_eq!(reply("Ending with ? means a question."), "Whatever."); } #[test] #[ignore] -/// shouting -fn shouting() { - process_response_case("WATCH OUT!", "Whoa, chill out!"); +fn non_letters_with_question() { + assert_eq!(reply(":) ?"), "Sure."); } #[test] #[ignore] -/// non-letters with question -fn nonletters_with_question() { - process_response_case(":) ?", "Sure."); +fn prattling_on() { + assert_eq!(reply("Wait! Hang on. Are you going to be OK?"), "Sure."); } #[test] #[ignore] -/// shouting gibberish -fn shouting_gibberish() { - process_response_case("FCECDFCAAB", "Whoa, chill out!"); +fn silence() { + assert_eq!(reply(""), "Fine. Be that way!"); } #[test] #[ignore] -/// asking a question -fn asking_a_question() { - process_response_case("Does this cryogenic chamber make me look fat?", "Sure."); +fn prolonged_silence() { + assert_eq!(reply(" "), "Fine. Be that way!"); } #[test] #[ignore] -/// asking a numeric question -fn asking_a_numeric_question() { - process_response_case("You are, what, like 15?", "Sure."); +fn alternate_silence() { + assert_eq!(reply("\t\t\t\t\t\t\t\t\t\t"), "Fine. Be that way!"); } #[test] #[ignore] -/// silence -fn silence() { - process_response_case("", "Fine. Be that way!"); +fn multiple_line_question() { + assert_eq!( + reply("\nDoes this cryogenic chamber make me look fat?\nNo."), + "Whatever." + ); } #[test] #[ignore] -/// starting with whitespace fn starting_with_whitespace() { - process_response_case(" hmmmmmmm...", "Whatever."); + assert_eq!(reply(" hmmmmmmm..."), "Whatever."); } #[test] #[ignore] -/// using acronyms in regular speech -fn using_acronyms_in_regular_speech() { - process_response_case( - "It's OK if you don't want to go work for NASA.", - "Whatever.", - ); +fn ending_with_whitespace() { + assert_eq!(reply("Okay if like my spacebar quite a bit? "), "Sure."); } #[test] #[ignore] -/// alternate silence -fn alternate_silence() { - process_response_case(" ", "Fine. Be that way!"); +fn other_whitespace() { + assert_eq!(reply("\n\r \t"), "Fine. Be that way!"); } #[test] #[ignore] -/// prolonged silence -fn prolonged_silence() { - process_response_case(" ", "Fine. Be that way!"); +fn non_question_ending_with_whitespace() { + assert_eq!( + reply("This is a statement ending with whitespace "), + "Whatever." + ); }