diff options
Diffstat (limited to 'odb-tests/mysql/index')
-rw-r--r-- | odb-tests/mysql/index/buildfile | 34 | ||||
-rw-r--r-- | odb-tests/mysql/index/driver.cxx | 44 | ||||
-rw-r--r-- | odb-tests/mysql/index/test.hxx | 20 | ||||
-rw-r--r-- | odb-tests/mysql/index/testscript | 11 |
4 files changed, 109 insertions, 0 deletions
diff --git a/odb-tests/mysql/index/buildfile b/odb-tests/mysql/index/buildfile new file mode 100644 index 0000000..9cadce3 --- /dev/null +++ b/odb-tests/mysql/index/buildfile @@ -0,0 +1,34 @@ +# file : mysql/index/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix mysql_index_ \ + --generate-schema \ + --default-database common + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/index/driver.cxx b/odb-tests/mysql/index/driver.cxx new file mode 100644 index 0000000..4d0b7ad --- /dev/null +++ b/odb-tests/mysql/index/driver.cxx @@ -0,0 +1,44 @@ +// file : mysql/index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test MySQL index creation. See also the common test. +// + +#include <memory> // std::unique_ptr +#include <iostream> + +#include <odb/mysql/database.hxx> +#include <odb/mysql/transaction.hxx> + +#include <libcommon/common.hxx> + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include <cassert> + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + try + { + // This is just a schema creation test. + // + unique_ptr<database> db (create_specific_database<database> (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/index/test.hxx b/odb-tests/mysql/index/test.hxx new file mode 100644 index 0000000..b4f6ae8 --- /dev/null +++ b/odb-tests/mysql/index/test.hxx @@ -0,0 +1,20 @@ +// file : mysql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <string> +#include <odb/core.hxx> + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + std::string s; + #pragma db index method("BTREE") member(s, "(200) DESC") +}; + +#endif // TEST_HXX diff --git a/odb-tests/mysql/index/testscript b/odb-tests/mysql/index/testscript new file mode 100644 index 0000000..26dfc4f --- /dev/null +++ b/odb-tests/mysql/index/testscript @@ -0,0 +1,11 @@ +# file : mysql/index/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + ++$create_schema + +: basics +: +$* |