public void test_row() { using (sqlite3 db = ugly.open(":memory:")) { db.exec("CREATE TABLE foo (x int, v int, t text, d real, b blob, q blob);"); byte[] blob = db.query_scalar <byte[]>("SELECT randomblob(5);"); db.exec("INSERT INTO foo (x,v,t,d,b,q) VALUES (?,?,?,?,?,?)", 32, 44, "hello", 3.14, blob, null); foreach (row r in db.query <row>("SELECT x,v,t,d,b,q FROM foo;")) { Assert.AreEqual(r.x, 32); Assert.AreEqual(r.v, 44); Assert.AreEqual(r.t, "hello"); Assert.AreEqual(r.d, 3.14); Assert.AreEqual(r.b.Length, blob.Length); for (int i = 0; i < blob.Length; i++) { Assert.AreEqual(r.b[i], blob[i]); } Assert.AreEqual(r.q, null); } using (sqlite3_stmt stmt = db.prepare("SELECT x,v,t,d,b,q FROM foo;")) { stmt.step(); Assert.AreEqual(stmt.db_handle(), db); Assert.AreEqual(stmt.column_int(0), 32); Assert.AreEqual(stmt.column_int64(1), 44); Assert.AreEqual(stmt.column_text(2), "hello"); Assert.AreEqual(stmt.column_double(3), 3.14); Assert.AreEqual(stmt.column_bytes(4), blob.Length); byte[] b2 = stmt.column_blob(4); Assert.AreEqual(b2.Length, blob.Length); for (int i = 0; i < blob.Length; i++) { Assert.AreEqual(b2[i], blob[i]); } Assert.AreEqual(stmt.column_type(5), raw.SQLITE_NULL); Assert.AreEqual(stmt.column_name(0), "x"); Assert.AreEqual(stmt.column_name(1), "v"); Assert.AreEqual(stmt.column_name(2), "t"); Assert.AreEqual(stmt.column_name(3), "d"); Assert.AreEqual(stmt.column_name(4), "b"); Assert.AreEqual(stmt.column_name(5), "q"); } } }