Skip to content

Commit a77de24

Browse files
committed
bob: Updated the exercise to the 1.4.0 version
Relevant PRs: - exercism/problem-specifications#1282 - exercism/problem-specifications#1293 - exercism/problem-specifications#1319 Appart from the new tests, some old tests were renamed / got their input value modified.
1 parent a9f0edd commit a77de24

File tree

2 files changed

+41
-49
lines changed

2 files changed

+41
-49
lines changed

exercises/bob/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[package]
22
name = "bob"
3-
version = "1.2.0"
3+
version = "1.4.0"

exercises/bob/tests/bob.rs

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,166 @@
11
extern crate bob;
22

3+
fn process_response_case(phrase: &str, expected_response: &str) {
4+
assert_eq!(bob::reply(phrase), expected_response);
5+
}
6+
37
#[test]
48
fn test_stating_something() {
5-
assert_eq!("Whatever.", bob::reply("Tom-ay-to, tom-aaaah-to."));
9+
process_response_case("Tom-ay-to, tom-aaaah-to.", "Whatever.");
610
}
711

812
#[test]
913
#[ignore]
1014
fn test_shouting() {
11-
assert_eq!("Whoa, chill out!", bob::reply("WATCH OUT!"));
15+
process_response_case("WATCH OUT!", "Whoa, chill out!");
1216
}
1317

1418
#[test]
1519
#[ignore]
1620
fn test_shouting_gibberish() {
17-
assert_eq!("Whoa, chill out!", bob::reply("FCECDFCAAB"));
21+
process_response_case("FCECDFCAAB", "Whoa, chill out!");
1822
}
1923

2024
#[test]
2125
#[ignore]
22-
fn test_asking() {
23-
assert_eq!(
24-
"Sure.",
25-
bob::reply("Does this cryogenic chamber make me look fat?")
26-
);
26+
fn test_asking_a_question() {
27+
process_response_case("Does this cryogenic chamber make me look fat?", "Sure.");
2728
}
2829

2930
#[test]
3031
#[ignore]
31-
fn test_ask_numeric_question() {
32-
assert_eq!("Sure.", bob::reply("You are, what, like 15?"));
32+
fn test_asking_a_numeric_question() {
33+
process_response_case("You are, what, like 15?", "Sure.");
3334
}
3435

3536
#[test]
3637
#[ignore]
3738
fn test_asking_gibberish() {
38-
assert_eq!("Sure.", bob::reply("fffbbcbeab?"));
39+
process_response_case("fffbbcbeab?", "Sure.");
3940
}
4041

4142
#[test]
4243
#[ignore]
43-
fn test_exclaiming() {
44-
assert_eq!("Whatever.", bob::reply("Let's go make out behind the gym!"));
44+
fn test_talking_forcefully() {
45+
process_response_case("Let's go make out behind the gym!", "Whatever.");
4546
}
4647

4748
#[test]
4849
#[ignore]
4950
fn test_using_acronyms_in_regular_speech() {
50-
assert_eq!(
51-
"Whatever.",
52-
bob::reply("It's OK if you don't want to go to the DMV.")
53-
);
51+
process_response_case("It's OK if you don't want to go to the DMV.", "Whatever.");
5452
}
5553

5654
#[test]
5755
#[ignore]
5856
fn test_forceful_question() {
59-
assert_eq!(
57+
process_response_case(
58+
"WHAT THE HELL WERE YOU THINKING?",
6059
"Calm down, I know what I'm doing!",
61-
bob::reply("WHAT THE HELL WERE YOU THINKING?")
6260
);
6361
}
6462

6563
#[test]
6664
#[ignore]
6765
fn test_shouting_numbers() {
68-
assert_eq!("Whoa, chill out!", bob::reply("1, 2, 3 GO!"));
66+
process_response_case("1, 2, 3 GO!", "Whoa, chill out!");
6967
}
7068

7169
#[test]
7270
#[ignore]
73-
fn test_only_numbers() {
74-
assert_eq!("Whatever.", bob::reply("1, 2, 3"));
71+
fn test_no_letters() {
72+
process_response_case("1, 2, 3", "Whatever.");
7573
}
7674

7775
#[test]
7876
#[ignore]
79-
fn test_question_with_only_numbers() {
80-
assert_eq!("Sure.", bob::reply("4?"));
77+
fn test_question_with_no_letters() {
78+
process_response_case("4?", "Sure.");
8179
}
8280

8381
#[test]
8482
#[ignore]
8583
fn test_shouting_with_special_characters() {
86-
assert_eq!(
84+
process_response_case(
85+
"ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!",
8786
"Whoa, chill out!",
88-
bob::reply("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
8987
);
9088
}
9189

9290
#[test]
9391
#[ignore]
9492
fn test_shouting_with_no_exclamation_mark() {
95-
assert_eq!("Whoa, chill out!", bob::reply("I HATE YOU"));
93+
process_response_case("I HATE THE DMV", "Whoa, chill out!");
9694
}
9795

9896
#[test]
9997
#[ignore]
10098
fn test_statement_containing_question_mark() {
101-
assert_eq!("Whatever.", bob::reply("Ending with ? means a question."));
99+
process_response_case("Ending with ? means a question.", "Whatever.");
102100
}
103101

104102
#[test]
105103
#[ignore]
106-
fn test_non_letters_with_question() {
107-
assert_eq!("Sure.", bob::reply(":) ?"));
104+
fn test_nonletters_with_question() {
105+
process_response_case(":) ?", "Sure.");
108106
}
109107

110108
#[test]
111109
#[ignore]
112110
fn test_prattling_on() {
113-
assert_eq!(
114-
"Sure.",
115-
bob::reply("Wait! Hang on. Are you going to be OK?")
116-
);
111+
process_response_case("Wait! Hang on. Are you going to be OK?", "Sure.");
117112
}
118113

119114
#[test]
120115
#[ignore]
121116
fn test_silence() {
122-
assert_eq!("Fine. Be that way!", bob::reply(""));
117+
process_response_case("", "Fine. Be that way!");
123118
}
124119

125120
#[test]
126121
#[ignore]
127122
fn test_prolonged_silence() {
128-
assert_eq!("Fine. Be that way!", bob::reply(" "));
123+
process_response_case(" ", "Fine. Be that way!");
129124
}
130125

131126
#[test]
132127
#[ignore]
133128
fn test_alternate_silence() {
134-
assert_eq!("Fine. Be that way!", bob::reply("\t\t\t\t\t\t\t\t\t\t"));
129+
process_response_case("\t\t\t\t\t\t\t\t\t\t", "Fine. Be that way!");
135130
}
136131

137132
#[test]
138133
#[ignore]
139134
fn test_multiple_line_question() {
140-
assert_eq!(
135+
process_response_case(
136+
"\nDoes this cryogenic chamber make me look fat?\nNo.",
141137
"Whatever.",
142-
bob::reply("\nDoes this cryogenic chamber make me look fat?\nno")
143138
);
144139
}
145140

146141
#[test]
147142
#[ignore]
148143
fn test_starting_with_whitespace() {
149-
assert_eq!("Whatever.", bob::reply(" hmmmmmmm..."));
144+
process_response_case(" hmmmmmmm...", "Whatever.");
150145
}
151146

152147
#[test]
153148
#[ignore]
154149
fn test_ending_with_whitespace() {
155-
assert_eq!(
156-
"Sure.",
157-
bob::reply("Okay if like my spacebar quite a bit? ")
158-
);
150+
process_response_case("Okay if like my spacebar quite a bit? ", "Sure.");
159151
}
160152

161153
#[test]
162154
#[ignore]
163155
fn test_other_whitespace() {
164-
assert_eq!("Fine. Be that way!", bob::reply("\n\r \t"));
156+
process_response_case("\n\r \t", "Fine. Be that way!");
165157
}
166158

167159
#[test]
168160
#[ignore]
169-
fn test_non_question_ending_with_whitespace() {
170-
assert_eq!(
161+
fn test_nonquestion_ending_with_whitespace() {
162+
process_response_case(
163+
"This is a statement ending with whitespace ",
171164
"Whatever.",
172-
bob::reply("This is a statement ending with whitespace ")
173165
);
174166
}

0 commit comments

Comments
 (0)