X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/ece97615567c7bc537f960d1784d652b11c0e66c..9dfa98b71aca915f8daf3b5c8a4ad702a1f9e8da:/src/lib.rs?ds=inline diff --git a/src/lib.rs b/src/lib.rs index 820f43e..0584cd2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,50 @@ +#[cfg(test)] +use std::io::BufRead; +#[cfg(test)] +use std::iter::Iterator; + +#[derive(Debug, PartialEq, Eq)] +struct RowInput { + label: String, + entries: Vec, +} + +#[cfg(test)] +fn read_rows(input: impl std::io::Read) -> impl Iterator { + vec![RowInput { + label: std::io::BufReader::new(input) + .lines() + .nth(0) + .unwrap() + .unwrap(), + entries: vec![], + }] + .into_iter() +} + pub fn tablify(_input: &impl std::io::Read) -> String { String::from("Hello, world!") } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_read_rows() { + assert_eq!( + read_rows(&b"foo"[..]).collect::>(), + vec![RowInput { + label: String::from("foo"), + entries: vec![] + }] + ); + assert_eq!( + read_rows(&b"bar"[..]).collect::>(), + vec![RowInput { + label: String::from("bar"), + entries: vec![] + }] + ); + } +}