]> git.scottworley.com Git - tablify/commitdiff
Read one row header
authorScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 07:12:54 +0000 (00:12 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 07:12:54 +0000 (00:12 -0700)
src/lib.rs

index 0e2007d389f178fa37255d5ff9e47a4861916420..0584cd20406662282a66cb7466bd371ab1b0b5a7 100644 (file)
@@ -1,4 +1,6 @@
 #[cfg(test)]
 #[cfg(test)]
+use std::io::BufRead;
+#[cfg(test)]
 use std::iter::Iterator;
 
 #[derive(Debug, PartialEq, Eq)]
 use std::iter::Iterator;
 
 #[derive(Debug, PartialEq, Eq)]
@@ -8,9 +10,13 @@ struct RowInput {
 }
 
 #[cfg(test)]
 }
 
 #[cfg(test)]
-fn read_rows(_input: &impl std::io::Read) -> impl Iterator<Item = RowInput> {
+fn read_rows(input: impl std::io::Read) -> impl Iterator<Item = RowInput> {
     vec![RowInput {
     vec![RowInput {
-        label: String::from("foo"),
+        label: std::io::BufReader::new(input)
+            .lines()
+            .nth(0)
+            .unwrap()
+            .unwrap(),
         entries: vec![],
     }]
     .into_iter()
         entries: vec![],
     }]
     .into_iter()
@@ -27,11 +33,18 @@ mod tests {
     #[test]
     fn test_read_rows() {
         assert_eq!(
     #[test]
     fn test_read_rows() {
         assert_eq!(
-            read_rows(&&b"foo"[..]).collect::<Vec<_>>(),
+            read_rows(&b"foo"[..]).collect::<Vec<_>>(),
             vec![RowInput {
                 label: String::from("foo"),
                 entries: vec![]
             }]
         );
             vec![RowInput {
                 label: String::from("foo"),
                 entries: vec![]
             }]
         );
+        assert_eq!(
+            read_rows(&b"bar"[..]).collect::<Vec<_>>(),
+            vec![RowInput {
+                label: String::from("bar"),
+                entries: vec![]
+            }]
+        );
     }
 }
     }
 }