From 9dfa98b71aca915f8daf3b5c8a4ad702a1f9e8da Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 19 Aug 2024 00:12:54 -0700 Subject: [PATCH] Read one row header --- src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0e2007d..0584cd2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,6 @@ #[cfg(test)] +use std::io::BufRead; +#[cfg(test)] use std::iter::Iterator; #[derive(Debug, PartialEq, Eq)] @@ -8,9 +10,13 @@ struct RowInput { } #[cfg(test)] -fn read_rows(_input: &impl std::io::Read) -> impl Iterator { +fn read_rows(input: impl std::io::Read) -> impl Iterator { vec![RowInput { - label: String::from("foo"), + label: std::io::BufReader::new(input) + .lines() + .nth(0) + .unwrap() + .unwrap(), entries: vec![], }] .into_iter() @@ -27,11 +33,18 @@ mod tests { #[test] fn test_read_rows() { assert_eq!( - read_rows(&&b"foo"[..]).collect::>(), + 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![] + }] + ); } } -- 2.44.1