diff options
Diffstat (limited to 'odb-tests/common/types')
-rw-r--r-- | odb-tests/common/types/buildfile | 39 | ||||
-rw-r--r-- | odb-tests/common/types/driver.cxx | 37 | ||||
-rw-r--r-- | odb-tests/common/types/test.hxx | 55 | ||||
-rw-r--r-- | odb-tests/common/types/testscript | 6 |
4 files changed, 137 insertions, 0 deletions
diff --git a/odb-tests/common/types/buildfile b/odb-tests/common/types/buildfile new file mode 100644 index 0000000..95fe5b6 --- /dev/null +++ b/odb-tests/common/types/buildfile @@ -0,0 +1,39 @@ +# file : common/types/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-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} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: 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 types_ + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/types/driver.cxx b/odb-tests/common/types/driver.cxx new file mode 100644 index 0000000..bdc66b8 --- /dev/null +++ b/odb-tests/common/types/driver.cxx @@ -0,0 +1,37 @@ +// file : common/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test C++ type handling (anonymous types, aliasing). +// + +#include <memory> +#include <iostream> + +#include <libcommon/common.hxx> + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include <cassert> + +using namespace std; +using namespace odb::core; + +template <typename T1, typename T2> +struct same_p +{ + static const bool result = false; +}; + +template <typename T> +struct same_p<T, T> +{ + static const bool result = true; +}; + +int +main () +{ + assert ((same_p<odb::object_traits<object2>::id_type, int>::result)); +} diff --git a/odb-tests/common/types/test.hxx b/odb-tests/common/types/test.hxx new file mode 100644 index 0000000..a99b499 --- /dev/null +++ b/odb-tests/common/types/test.hxx @@ -0,0 +1,55 @@ +// file : common/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#ifdef ODB_COMPILER +typedef int int_t; +typedef short num_t; +#else +typedef int num_t; +#endif + +typedef num_t num_type; + +#pragma db object +struct object1 +{ + typedef int int_type; + + #pragma db id + int_type id_; +}; + +#pragma db object +struct object2 +{ + #pragma db id + num_type num_; +}; + +// Template-id with "inner" name (compilation test). +// +template <typename X> +struct num_wrap +{ +#ifdef ODB_COMPILER + typedef num_wrap this_type; // Name that we should not use. +#endif + + num_wrap () {} + num_wrap (X v): v_ (v) {} + operator X () const {return v_;} + + X v_; +}; + +#pragma db object +struct object3 +{ + #pragma db id type("INTEGER") + num_wrap<long long> num_; // Use long long to avoid warnings. +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/types/testscript b/odb-tests/common/types/testscript new file mode 100644 index 0000000..159972b --- /dev/null +++ b/odb-tests/common/types/testscript @@ -0,0 +1,6 @@ +# file : common/types/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basic +: +$* |