]>
Commit | Line | Data |
---|---|---|
75bb888a | 1 | #[cfg(test)] |
9dfa98b7 SW |
2 | use std::io::BufRead; |
3 | #[cfg(test)] | |
75bb888a SW |
4 | use std::iter::Iterator; |
5 | ||
6 | #[derive(Debug, PartialEq, Eq)] | |
7 | struct RowInput { | |
8 | label: String, | |
9 | entries: Vec<String>, | |
10 | } | |
11 | ||
12 | #[cfg(test)] | |
9dfa98b7 | 13 | fn read_rows(input: impl std::io::Read) -> impl Iterator<Item = RowInput> { |
75bb888a | 14 | vec![RowInput { |
9dfa98b7 SW |
15 | label: std::io::BufReader::new(input) |
16 | .lines() | |
17 | .nth(0) | |
18 | .unwrap() | |
19 | .unwrap(), | |
75bb888a SW |
20 | entries: vec![], |
21 | }] | |
22 | .into_iter() | |
23 | } | |
24 | ||
ece97615 SW |
25 | pub fn tablify(_input: &impl std::io::Read) -> String { |
26 | String::from("Hello, world!") | |
27 | } | |
75bb888a SW |
28 | |
29 | #[cfg(test)] | |
30 | mod tests { | |
31 | use super::*; | |
32 | ||
33 | #[test] | |
34 | fn test_read_rows() { | |
35 | assert_eq!( | |
9dfa98b7 | 36 | read_rows(&b"foo"[..]).collect::<Vec<_>>(), |
75bb888a SW |
37 | vec![RowInput { |
38 | label: String::from("foo"), | |
39 | entries: vec![] | |
40 | }] | |
41 | ); | |
9dfa98b7 SW |
42 | assert_eq!( |
43 | read_rows(&b"bar"[..]).collect::<Vec<_>>(), | |
44 | vec![RowInput { | |
45 | label: String::from("bar"), | |
46 | entries: vec![] | |
47 | }] | |
48 | ); | |
75bb888a SW |
49 | } |
50 | } |