-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathmagazine-cutout.rs
More file actions
72 lines (65 loc) · 2.22 KB
/
magazine-cutout.rs
File metadata and controls
72 lines (65 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use magazine_cutout::*;
#[test]
fn magazine_has_fewer_words_available_than_needed() {
let magazine = "two times three is not four"
.split_whitespace()
.collect::<Vec<&str>>();
let note = "two times two is four"
.split_whitespace()
.collect::<Vec<&str>>();
assert!(!can_construct_note(&magazine, ¬e));
}
#[test]
#[ignore]
fn fn_returns_true_for_good_input() {
let magazine = "The metro orchestra unveiled its new grand piano today. Its donor paraphrased Nathn Hale: \"I only regret that I have but one to give \"".split_whitespace().collect::<Vec<&str>>();
let note = "give one grand today."
.split_whitespace()
.collect::<Vec<&str>>();
assert!(can_construct_note(&magazine, ¬e));
}
#[test]
#[ignore]
fn fn_returns_false_for_bad_input() {
let magazine = "I've got a lovely bunch of coconuts."
.split_whitespace()
.collect::<Vec<&str>>();
let note = "I've got som coconuts"
.split_whitespace()
.collect::<Vec<&str>>();
assert!(!can_construct_note(&magazine, ¬e));
}
#[test]
#[ignore]
fn case_sensitivity() {
let magazine = "i've got some lovely coconuts"
.split_whitespace()
.collect::<Vec<&str>>();
let note = "I've got some coconuts"
.split_whitespace()
.collect::<Vec<&str>>();
assert!(!can_construct_note(&magazine, ¬e));
let magazine = "I've got some lovely coconuts"
.split_whitespace()
.collect::<Vec<&str>>();
let note = "i've got some coconuts"
.split_whitespace()
.collect::<Vec<&str>>();
assert!(!can_construct_note(&magazine, ¬e));
}
#[test]
#[ignore]
fn magazine_has_more_words_available_than_needed() {
let magazine = "Enough is enough when enough is enough"
.split_whitespace()
.collect::<Vec<&str>>();
let note = "enough is enough".split_whitespace().collect::<Vec<&str>>();
assert!(can_construct_note(&magazine, ¬e));
}
#[test]
#[ignore]
fn magazine_has_one_good_word_many_times_but_still_cant_construct() {
let magazine = "A A A".split_whitespace().collect::<Vec<&str>>();
let note = "A nice day".split_whitespace().collect::<Vec<&str>>();
assert!(!can_construct_note(&magazine, ¬e));
}