]> git.scottworley.com Git - tablify/blob - src/lib.rs
Read one row header
[tablify] / src / lib.rs
1 #[cfg(test)]
2 use std::io::BufRead;
3 #[cfg(test)]
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)]
13 fn read_rows(input: impl std::io::Read) -> impl Iterator<Item = RowInput> {
14 vec![RowInput {
15 label: std::io::BufReader::new(input)
16 .lines()
17 .nth(0)
18 .unwrap()
19 .unwrap(),
20 entries: vec![],
21 }]
22 .into_iter()
23 }
24
25 pub fn tablify(_input: &impl std::io::Read) -> String {
26 String::from("Hello, world!")
27 }
28
29 #[cfg(test)]
30 mod tests {
31 use super::*;
32
33 #[test]
34 fn test_read_rows() {
35 assert_eq!(
36 read_rows(&b"foo"[..]).collect::<Vec<_>>(),
37 vec![RowInput {
38 label: String::from("foo"),
39 entries: vec![]
40 }]
41 );
42 assert_eq!(
43 read_rows(&b"bar"[..]).collect::<Vec<_>>(),
44 vec![RowInput {
45 label: String::from("bar"),
46 entries: vec![]
47 }]
48 );
49 }
50 }