Skip to content

Commit 4d0bcfc

Browse files
committed
parallel-letter-frequency: Move inputs under tests
1 parent 50d0072 commit 4d0bcfc

1 file changed

Lines changed: 73 additions & 72 deletions

File tree

exercises/practice/parallel-letter-frequency/tests/parallel_letter_frequency.rs

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,6 @@ use std::collections::HashMap;
22

33
use parallel_letter_frequency as frequency;
44

5-
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
6-
const ODE_AN_DIE_FREUDE: [&str; 8] = [
7-
"Freude schöner Götterfunken",
8-
"Tochter aus Elysium,",
9-
"Wir betreten feuertrunken,",
10-
"Himmlische, dein Heiligtum!",
11-
"Deine Zauber binden wieder",
12-
"Was die Mode streng geteilt;",
13-
"Alle Menschen werden Brüder,",
14-
"Wo dein sanfter Flügel weilt.",
15-
];
16-
17-
// Dutch national anthem
18-
const WILHELMUS: [&str; 8] = [
19-
"Wilhelmus van Nassouwe",
20-
"ben ik, van Duitsen bloed,",
21-
"den vaderland getrouwe",
22-
"blijf ik tot in den dood.",
23-
"Een Prinse van Oranje",
24-
"ben ik, vrij, onverveerd,",
25-
"den Koning van Hispanje",
26-
"heb ik altijd geëerd.",
27-
];
28-
29-
// American national anthem
30-
const STAR_SPANGLED_BANNER: [&str; 8] = [
31-
"O say can you see by the dawn's early light,",
32-
"What so proudly we hailed at the twilight's last gleaming,",
33-
"Whose broad stripes and bright stars through the perilous fight,",
34-
"O'er the ramparts we watched, were so gallantly streaming?",
35-
"And the rockets' red glare, the bombs bursting in air,",
36-
"Gave proof through the night that our flag was still there;",
37-
"O say does that star-spangled banner yet wave,",
38-
"O'er the land of the free and the home of the brave?",
39-
];
40-
415
#[test]
426
fn no_texts() {
437
assert_eq!(frequency::frequency(&[], 4), HashMap::new());
@@ -141,6 +105,7 @@ fn unicode_letters() {
141105
#[ignore]
142106
fn all_three_anthems_1_worker() {
143107
let mut v = Vec::new();
108+
// These constants can be found under the last test if you wish to see them
144109
for anthem in [ODE_AN_DIE_FREUDE, WILHELMUS, STAR_SPANGLED_BANNER].iter() {
145110
for line in anthem.iter() {
146111
v.push(*line);
@@ -178,6 +143,78 @@ fn non_integer_multiple_of_threads() {
178143
assert_eq!(frequency::frequency(&v[..], 4), hm);
179144
}
180145

146+
#[test]
147+
#[ignore]
148+
fn large_texts() {
149+
let expected: HashMap<char, usize> = [
150+
('a', 845),
151+
('b', 155),
152+
('c', 278),
153+
('d', 359),
154+
('e', 1143),
155+
('f', 222),
156+
('g', 187),
157+
('h', 507),
158+
('i', 791),
159+
('j', 12),
160+
('k', 67),
161+
('l', 423),
162+
('m', 288),
163+
('n', 833),
164+
('o', 791),
165+
('p', 197),
166+
('q', 8),
167+
('r', 432),
168+
('s', 700),
169+
('t', 1043),
170+
('u', 325),
171+
('v', 111),
172+
('w', 223),
173+
('x', 7),
174+
('y', 251),
175+
]
176+
.into_iter()
177+
.collect();
178+
179+
assert_eq!(frequency::frequency(&DOSTOEVSKY, 4), expected);
180+
}
181+
182+
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
183+
const ODE_AN_DIE_FREUDE: [&str; 8] = [
184+
"Freude schöner Götterfunken",
185+
"Tochter aus Elysium,",
186+
"Wir betreten feuertrunken,",
187+
"Himmlische, dein Heiligtum!",
188+
"Deine Zauber binden wieder",
189+
"Was die Mode streng geteilt;",
190+
"Alle Menschen werden Brüder,",
191+
"Wo dein sanfter Flügel weilt.",
192+
];
193+
194+
// Dutch national anthem
195+
const WILHELMUS: [&str; 8] = [
196+
"Wilhelmus van Nassouwe",
197+
"ben ik, van Duitsen bloed,",
198+
"den vaderland getrouwe",
199+
"blijf ik tot in den dood.",
200+
"Een Prinse van Oranje",
201+
"ben ik, vrij, onverveerd,",
202+
"den Koning van Hispanje",
203+
"heb ik altijd geëerd.",
204+
];
205+
206+
// American national anthem
207+
const STAR_SPANGLED_BANNER: [&str; 8] = [
208+
"O say can you see by the dawn's early light,",
209+
"What so proudly we hailed at the twilight's last gleaming,",
210+
"Whose broad stripes and bright stars through the perilous fight,",
211+
"O'er the ramparts we watched, were so gallantly streaming?",
212+
"And the rockets' red glare, the bombs bursting in air,",
213+
"Gave proof through the night that our flag was still there;",
214+
"O say does that star-spangled banner yet wave,",
215+
"O'er the land of the free and the home of the brave?",
216+
];
217+
181218
const DOSTOEVSKY: [&str; 4] = [
182219
r#"
183220
I am a sick man.... I am a spiteful man. I am an unattractive man.
@@ -323,39 +360,3 @@ const DOSTOEVSKY: [&str; 4] = [
323360
his worst defect is his perpetual moral obliquity, perpetual - from the days of the Flood to the Schleswig-Holstein period.
324361
"#,
325362
];
326-
327-
#[test]
328-
#[ignore]
329-
fn large_texts() {
330-
let expected: HashMap<char, usize> = [
331-
('a', 845),
332-
('b', 155),
333-
('c', 278),
334-
('d', 359),
335-
('e', 1143),
336-
('f', 222),
337-
('g', 187),
338-
('h', 507),
339-
('i', 791),
340-
('j', 12),
341-
('k', 67),
342-
('l', 423),
343-
('m', 288),
344-
('n', 833),
345-
('o', 791),
346-
('p', 197),
347-
('q', 8),
348-
('r', 432),
349-
('s', 700),
350-
('t', 1043),
351-
('u', 325),
352-
('v', 111),
353-
('w', 223),
354-
('x', 7),
355-
('y', 251),
356-
]
357-
.into_iter()
358-
.collect();
359-
360-
assert_eq!(frequency::frequency(&DOSTOEVSKY, 4), expected);
361-
}

0 commit comments

Comments
 (0)