Skip to content

Commit 6de3931

Browse files
authored
Merge pull request exercism#145 from IanWhitney/fixes
Collection of small test fixes
2 parents b506e41 + 7ae85f6 commit 6de3931

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

exercises/allergies/tests/allergies.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ extern crate allergies;
33
use allergies::*;
44

55
fn compare_allergy_vectors(expected: &Vec<Allergen>, actual: &Vec<Allergen>) {
6-
if !expected.iter().eq(actual.iter()) {
7-
panic!("Expected {:?}, got {:?}", expected, actual);
6+
for element in expected {
7+
if !actual.contains(element) {
8+
panic!("Allergen missing\n {:?} should be in {:?}",
9+
element,
10+
actual);
11+
}
12+
}
13+
14+
if actual.len() != expected.len() {
15+
panic!("Allergy vectors are of different lengths\n expected {:?}\n got {:?}",
16+
expected,
17+
actual);
818
}
919
}
1020

exercises/pangram/tests/pangram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn numbers_do_not_affect_pangrams() {
4545

4646
#[test]
4747
#[ignore]
48-
fn numbers_can_not_replace_numbers() {
48+
fn numbers_can_not_replace_letters() {
4949
let sentence = "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog";
5050
assert!(!is_pangram(&sentence));
5151
}

exercises/wordy/tests/wordy.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,90 +9,105 @@ fn addition() {
99
}
1010

1111
#[test]
12+
#[ignore]
1213
fn more_addition() {
1314
let command = "What is 53 plus 2?";
1415
assert_eq!(55, WordProblem::new(command).answer().unwrap());
1516
}
1617

1718
#[test]
19+
#[ignore]
1820
fn addition_with_negative_numbers() {
1921
let command = "What is -1 plus -10?";
2022
assert_eq!(-11, WordProblem::new(command).answer().unwrap());
2123
}
2224

2325
#[test]
26+
#[ignore]
2427
fn large_addition() {
2528
let command = "What is 123 plus 45678?";
2629
assert_eq!(45801, WordProblem::new(command).answer().unwrap());
2730
}
2831

2932
#[test]
33+
#[ignore]
3034
fn subtraction() {
3135
let command = "What is 4 minus -12?";
3236
assert_eq!(16, WordProblem::new(command).answer().unwrap());
3337
}
3438

3539
#[test]
40+
#[ignore]
3641
fn multiplication() {
3742
let command = "What is -3 multiplied by 25?";
3843
assert_eq!(-75, WordProblem::new(command).answer().unwrap());
3944
}
4045

4146
#[test]
47+
#[ignore]
4248
fn division() {
4349
let command = "What is 33 divided by -3?";
4450
assert_eq!(-11, WordProblem::new(command).answer().unwrap());
4551
}
4652

4753
#[test]
54+
#[ignore]
4855
fn multiple_additions() {
4956
let command = "What is 1 plus 1 plus 1?";
5057
assert_eq!(3, WordProblem::new(command).answer().unwrap());
5158
}
5259

5360
#[test]
61+
#[ignore]
5462
fn addition_and_subtraction() {
5563
let command = "What is 1 plus 5 minus -2?";
5664
assert_eq!(8, WordProblem::new(command).answer().unwrap());
5765
}
5866

5967
#[test]
68+
#[ignore]
6069
fn multiple_subtraction() {
6170
let command = "What is 20 minus 4 minus 13?";
6271
assert_eq!(3, WordProblem::new(command).answer().unwrap());
6372
}
6473

6574
#[test]
75+
#[ignore]
6676
fn subtraction_then_addition() {
6777
let command = "What is 17 minus 6 plus 3?";
6878
assert_eq!(14, WordProblem::new(command).answer().unwrap());
6979
}
7080

7181
#[test]
82+
#[ignore]
7283
fn multiple_multiplications() {
7384
let command = "What is 2 multiplied by -2 multiplied by 3?";
7485
assert_eq!(-12, WordProblem::new(command).answer().unwrap());
7586
}
7687

7788
#[test]
89+
#[ignore]
7890
fn addition_and_multiplication() {
7991
let command = "What is -3 plus 7 multiplied by -2?";
8092
assert_eq!(-8, WordProblem::new(command).answer().unwrap());
8193
}
8294

8395
#[test]
96+
#[ignore]
8497
fn multiple_divisions() {
8598
let command = "What is -12 divided by 2 divided by -3?";
8699
assert_eq!(2, WordProblem::new(command).answer().unwrap());
87100
}
88101

89102
#[test]
103+
#[ignore]
90104
fn unknown_operation() {
91105
let command = "What is 52 cubed?";
92106
assert!(WordProblem::new(command).answer().is_err());
93107
}
94108

95109
#[test]
110+
#[ignore]
96111
fn non_math_question() {
97112
let command = "Who is the President of the United States?";
98113
assert!(WordProblem::new(command).answer().is_err());

0 commit comments

Comments
 (0)