diff options
Diffstat (limited to 'libodb-sqlite/tests')
-rw-r--r-- | libodb-sqlite/tests/.gitignore | 1 | ||||
-rw-r--r-- | libodb-sqlite/tests/basics/buildfile | 6 | ||||
-rw-r--r-- | libodb-sqlite/tests/basics/driver.cxx | 52 | ||||
-rw-r--r-- | libodb-sqlite/tests/build/.gitignore | 3 | ||||
-rw-r--r-- | libodb-sqlite/tests/build/bootstrap.build | 8 | ||||
-rw-r--r-- | libodb-sqlite/tests/build/root.build | 23 | ||||
-rw-r--r-- | libodb-sqlite/tests/buildfile | 4 |
7 files changed, 97 insertions, 0 deletions
diff --git a/libodb-sqlite/tests/.gitignore b/libodb-sqlite/tests/.gitignore new file mode 100644 index 0000000..e54525b --- /dev/null +++ b/libodb-sqlite/tests/.gitignore @@ -0,0 +1 @@ +driver diff --git a/libodb-sqlite/tests/basics/buildfile b/libodb-sqlite/tests/basics/buildfile new file mode 100644 index 0000000..5d671d3 --- /dev/null +++ b/libodb-sqlite/tests/basics/buildfile @@ -0,0 +1,6 @@ +# file : tests/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb-sqlite%lib{odb-sqlite} + +exe{driver}: {hxx cxx}{*} $libs diff --git a/libodb-sqlite/tests/basics/driver.cxx b/libodb-sqlite/tests/basics/driver.cxx new file mode 100644 index 0000000..b998574 --- /dev/null +++ b/libodb-sqlite/tests/basics/driver.cxx @@ -0,0 +1,52 @@ +// file : tests/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Basic test to make sure the library is usable. Functionality testing +// is done in the odb-tests package. + +#include <cassert> +#include <sstream> + +#include <odb/sqlite/database.hxx> +#include <odb/sqlite/exceptions.hxx> +#include <odb/sqlite/transaction.hxx> + +using namespace odb::sqlite; + +int +main () +{ + { + std::ostringstream os; + database::print_usage (os); + assert (!os.str ().empty ()); + } + + database db (":memory:"); + + { + transaction t (db.begin ()); + db.execute ("CREATE TABLE test (id INTEGER PRIMARY KEY, str TEXT)"); + t.commit (); + } + + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'abc')"); + t.commit (); + } + + try + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'ABC')"); + assert (false); + } + catch (const database_exception&) {} + + { + transaction t (db.begin ()); + db.execute ("DROP TABLE test"); + t.commit (); + } +} diff --git a/libodb-sqlite/tests/build/.gitignore b/libodb-sqlite/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libodb-sqlite/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libodb-sqlite/tests/build/bootstrap.build b/libodb-sqlite/tests/build/bootstrap.build new file mode 100644 index 0000000..6ee38db --- /dev/null +++ b/libodb-sqlite/tests/build/bootstrap.build @@ -0,0 +1,8 @@ +# file : tests/build/bootstrap.build +# license : GNU GPL v2; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/libodb-sqlite/tests/build/root.build b/libodb-sqlite/tests/build/root.build new file mode 100644 index 0000000..6c5a90b --- /dev/null +++ b/libodb-sqlite/tests/build/root.build @@ -0,0 +1,23 @@ +# file : tests/build/root.build +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/libodb-sqlite/tests/buildfile b/libodb-sqlite/tests/buildfile new file mode 100644 index 0000000..57588a4 --- /dev/null +++ b/libodb-sqlite/tests/buildfile @@ -0,0 +1,4 @@ +# file : tests/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -build/} |