From 414cff0779dd9bd1af709be5cd7181d9b7d3110e Mon Sep 17 00:00:00 2001 From: Alexey Proshutinskiy Date: Thu, 2 Sep 2021 15:02:39 +0300 Subject: [PATCH] update test --- src/test.rs | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/test.rs b/src/test.rs index 6a281c8..e1d2002 100644 --- a/src/test.rs +++ b/src/test.rs @@ -94,16 +94,52 @@ pub fn test4() { connection .execute( " - CREATE TABLE users (name TEXT, age BLOB NOT NULL); + CREATE TABLE test (number INTEGER, blob BLOB NOT NULL); ", ) .unwrap(); let mut cursor = connection - .prepare("INSERT OR REPLACE INTO users VALUES (?, ?)").unwrap(); + .prepare("INSERT OR REPLACE INTO test VALUES (?, ?)").unwrap(); cursor.bind(1, &Value::Integer(50)).unwrap(); cursor.bind(2, &Value::Binary(vec![1, 2, 3])).unwrap(); cursor.next().unwrap(); } + +#[marine] +pub fn test5() { + use marine_sqlite_connector::Value; + + let connection = marine_sqlite_connector::open(":memory:").unwrap(); + + connection + .execute( + " + CREATE TABLE test (number INTEGER, blob BLOB); + ", + ) + .unwrap(); + + let mut cursor = connection + .prepare("INSERT OR REPLACE INTO test VALUES (?, ?)").unwrap(); + + cursor.bind(1, &Value::Integer(50)).unwrap(); + cursor.bind(2, &Value::Binary(vec![1, 2, 3])).unwrap(); + + cursor.next().unwrap(); + + let mut cursor = connection + .prepare("SELECT blob FROM test WHERE number = ?") + .unwrap() + .cursor(); + + cursor.bind(&[Value::Integer(50)]).unwrap(); + + while let Some(row) = cursor.next().unwrap() { + if vec![1,2 ,3] != row[0].as_binary().unwrap().to_vec() { + println!("expected: {:?}, actual: {:?}", vec![1,2 ,3], row[0].as_binary().unwrap()); + } + } +} \ No newline at end of file