mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Make tests return Result
This commit is contained in:
		| @@ -197,29 +197,30 @@ unsafe impl VTabCursor for ArrayTabCursor<'_> { | ||||
| mod test { | ||||
|     use crate::types::Value; | ||||
|     use crate::vtab::array; | ||||
|     use crate::Connection; | ||||
|     use crate::{Connection, Result}; | ||||
|     use std::rc::Rc; | ||||
|  | ||||
|     #[test] | ||||
|     fn test_array_module() { | ||||
|         let db = Connection::open_in_memory().unwrap(); | ||||
|         array::load_module(&db).unwrap(); | ||||
|     fn test_array_module() -> Result<()> { | ||||
|         let db = Connection::open_in_memory()?; | ||||
|         array::load_module(&db)?; | ||||
|  | ||||
|         let v = vec![1i64, 2, 3, 4]; | ||||
|         let values: Vec<Value> = v.into_iter().map(Value::from).collect(); | ||||
|         let ptr = Rc::new(values); | ||||
|         { | ||||
|             let mut stmt = db.prepare("SELECT value from rarray(?);").unwrap(); | ||||
|             let mut stmt = db.prepare("SELECT value from rarray(?);")?; | ||||
|  | ||||
|             let rows = stmt.query_map(&[&ptr], |row| row.get::<_, i64>(0)).unwrap(); | ||||
|             let rows = stmt.query_map(&[&ptr], |row| row.get::<_, i64>(0))?; | ||||
|             assert_eq!(2, Rc::strong_count(&ptr)); | ||||
|             let mut count = 0; | ||||
|             for (i, value) in rows.enumerate() { | ||||
|                 assert_eq!(i as i64, value.unwrap() - 1); | ||||
|                 assert_eq!(i as i64, value? - 1); | ||||
|                 count += 1; | ||||
|             } | ||||
|             assert_eq!(4, count); | ||||
|         } | ||||
|         assert_eq!(1, Rc::strong_count(&ptr)); | ||||
|         Ok(()) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user