From 879be9db4f7fb285eb42a3f0479eaed457870097 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 13 Aug 2016 17:33:58 +0200 Subject: Initial packaging, based on SQLite 3.14.1 --- test/.gitignore | 5 +++++ test/build/.gitignore | 1 + test/build/bootstrap.build | 8 +++++++ test/build/root.build | 8 +++++++ test/buildfile | 6 ++++++ test/driver.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 test/.gitignore create mode 100644 test/build/.gitignore create mode 100644 test/build/bootstrap.build create mode 100644 test/build/root.build create mode 100644 test/buildfile create mode 100644 test/driver.c (limited to 'test') diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..001d4db --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,5 @@ +driver +driver.exe + +*.exe.dlls/ +*.exe.manifest diff --git a/test/build/.gitignore b/test/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/test/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/test/build/bootstrap.build b/test/build/bootstrap.build new file mode 100644 index 0000000..49e8cc2 --- /dev/null +++ b/test/build/bootstrap.build @@ -0,0 +1,8 @@ +# file : test/build/bootstrap.build +# copyright : not copyrighted - public domain + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/test/build/root.build b/test/build/root.build new file mode 100644 index 0000000..51b3178 --- /dev/null +++ b/test/build/root.build @@ -0,0 +1,8 @@ +# file : test/build/root.build +# copyright : not copyrighted - public domain + +using c + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true diff --git a/test/buildfile b/test/buildfile new file mode 100644 index 0000000..8e57333 --- /dev/null +++ b/test/buildfile @@ -0,0 +1,6 @@ +# file : test/buildfile +# copyright : not copyrighted - public domain + +import libs = libsqlite3%lib{sqlite} + +exe{driver}: c{driver} $libs diff --git a/test/driver.c b/test/driver.c new file mode 100644 index 0000000..d079a0d --- /dev/null +++ b/test/driver.c @@ -0,0 +1,54 @@ +/* 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); +} -- cgit v1.1