]> git.scottworley.com Git - tablify/commitdiff
read_rows() lies
authorScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 06:46:55 +0000 (23:46 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 06:46:55 +0000 (23:46 -0700)
src/lib.rs

index 820f43e172653f8f26e63b84abee7d8dadb6cb95..0e2007d389f178fa37255d5ff9e47a4861916420 100644 (file)
@@ -1,3 +1,37 @@
+#[cfg(test)]
+use std::iter::Iterator;
+
+#[derive(Debug, PartialEq, Eq)]
+struct RowInput {
+    label: String,
+    entries: Vec<String>,
+}
+
+#[cfg(test)]
+fn read_rows(_input: &impl std::io::Read) -> impl Iterator<Item = RowInput> {
+    vec![RowInput {
+        label: String::from("foo"),
+        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<_>>(),
+            vec![RowInput {
+                label: String::from("foo"),
+                entries: vec![]
+            }]
+        );
+    }
+}