From c9cc63908017c5aea0b18ab4e1c204c7eeac7434 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 6 Mar 2021 12:55:25 +0100 Subject: [PATCH] Add tests adapted from official SQLite tests --- src/vtab/series.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/vtab/series.rs b/src/vtab/series.rs index 72dce9f..80693cf 100644 --- a/src/vtab/series.rs +++ b/src/vtab/series.rs @@ -274,6 +274,7 @@ mod test { use crate::ffi; use crate::vtab::series; use crate::{Connection, Result}; + use fallible_iterator::FallibleIterator; #[test] fn test_series_module() -> Result<()> { @@ -294,6 +295,18 @@ mod test { assert_eq!(expected, value?); expected += 5; } + + let mut s = + db.prepare("SELECT * FROM generate_series WHERE start=1 AND stop=9 AND step=2")?; + let series: Vec = s.query([])?.map(|r| r.get(0)).collect()?; + assert_eq!(vec![1, 3, 5, 7, 9], series); + let mut s = db.prepare("SELECT * FROM generate_series LIMIT 5")?; + let series: Vec = s.query([])?.map(|r| r.get(0)).collect()?; + assert_eq!(vec![0, 1, 2, 3, 4], series); + let mut s = db.prepare("SELECT * FROM generate_series(0,32,5) ORDER BY value DESC")?; + let series: Vec = s.query([])?.map(|r| r.get(0)).collect()?; + assert_eq!(vec![30, 25, 20, 15, 10, 5, 0], series); + Ok(()) } }