Test series virtual table

This commit is contained in:
gwenn 2016-08-15 09:09:38 +02:00
parent b4db5666b6
commit 1d342ef5f3

View File

@ -242,3 +242,33 @@ impl VTabCursor<SeriesTab> for SeriesTabCursor {
Ok(self.row_id) Ok(self.row_id)
} }
} }
#[cfg(test)]
mod test {
use Connection;
use vtab::series;
use ffi;
#[test]
fn test_series_module() {
let version = unsafe { ffi::sqlite3_libversion_number() };
if version < 3008012 {
return;
}
let db = Connection::open_in_memory().unwrap();
series::load_module(&db).unwrap();
let mut s = db.prepare("SELECT * FROM generate_series(0,20,5)").unwrap();
let series = s.query_map(&[], |row| row.get(0))
.unwrap();
let mut expected = 0;
for value in series {
assert_eq!(expected, value.unwrap());
expected += 5;
}
}
}