From 3d3a63d289cdaa8bc4d4a3820d499ea5a3205b43 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 11 Mar 2019 16:47:49 +0300 Subject: Release version 3.18.2+7 Place libsqlite3 and sqlite3 packages into single repository. --- libsqlite3/test/driver.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 libsqlite3/test/driver.c (limited to 'libsqlite3/test/driver.c') diff --git a/libsqlite3/test/driver.c b/libsqlite3/test/driver.c new file mode 100644 index 0000000..2eabb06 --- /dev/null +++ b/libsqlite3/test/driver.c @@ -0,0 +1,56 @@ +/* file : test/driver.c + * copyright : not copyrighted - public domain + */ + +/* + * Basic test to make sure the library is usable. + */ + +#ifdef NDEBUG +# undef NDEBUG +#endif + +#include + +#include /* NULL */ +#include + +static int +sql (sqlite3* db, const char* stmt) +{ + return sqlite3_exec (db, stmt, NULL, NULL, NULL) == SQLITE_OK; +} + +int +main () +{ + sqlite3* db; + int r; + + r = sqlite3_open_v2 (":memory:", + &db, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, + NULL); + assert (r == SQLITE_OK); + + assert (sql (db, "BEGIN")); + assert (sql (db, "CREATE TABLE test (id INTEGER PRIMARY KEY, str TEXT)")); + assert (sql (db, "COMMIT")); + + assert (sql (db, "BEGIN")); + assert (sql (db, "INSERT INTO test VALUES (123, 'abc')")); + assert (sql (db, "COMMIT")); + + assert (sql (db, "BEGIN")); + assert (!sql (db, "INSERT INTO test VALUES (123, 'ABC')")); + assert (sql (db, "ROLLBACK")); + + assert (sql (db, "BEGIN")); + assert (sql (db, "DROP TABLE test")); + assert (sql (db, "COMMIT")); + + r = sqlite3_close (db); + assert (r == SQLITE_OK); + + return 0; +} -- cgit v1.1