diff options
Diffstat (limited to 'odb-tests/common/include')
-rw-r--r-- | odb-tests/common/include/.gitignore | 17 | ||||
-rw-r--r-- | odb-tests/common/include/buildfile | 51 | ||||
-rw-r--r-- | odb-tests/common/include/driver.cxx | 42 | ||||
-rw-r--r-- | odb-tests/common/include/obj1.hxx | 25 | ||||
-rw-r--r-- | odb-tests/common/include/obj2.hxx | 25 | ||||
-rw-r--r-- | odb-tests/common/include/obj3.hxx | 25 | ||||
-rw-r--r-- | odb-tests/common/include/objs1.hxx | 13 | ||||
-rw-r--r-- | odb-tests/common/include/objs2.hxx | 13 | ||||
-rw-r--r-- | odb-tests/common/include/objs3.hxx | 11 | ||||
-rw-r--r-- | odb-tests/common/include/objs4.hxx | 11 | ||||
-rw-r--r-- | odb-tests/common/include/test1.hxx | 16 | ||||
-rw-r--r-- | odb-tests/common/include/test2.hxx | 15 | ||||
-rw-r--r-- | odb-tests/common/include/test3.hxx | 12 | ||||
-rw-r--r-- | odb-tests/common/include/test4.hxx | 12 | ||||
-rw-r--r-- | odb-tests/common/include/testscript | 31 |
15 files changed, 319 insertions, 0 deletions
diff --git a/odb-tests/common/include/.gitignore b/odb-tests/common/include/.gitignore new file mode 100644 index 0000000..d52f166 --- /dev/null +++ b/odb-tests/common/include/.gitignore @@ -0,0 +1,17 @@ +# ODB-generated files. +# +obj1-odb.?xx +obj1-odb-*.?xx +obj2-odb.?xx +obj2-odb-*.?xx +obj3-odb.?xx +obj3-odb-*.?xx + +test1-odb.?xx +test1-odb-*.?xx +test2-odb.?xx +test2-odb-*.?xx +test3-odb.?xx +test3-odb-*.?xx +test4-odb.?xx +test4-odb-*.?xx diff --git a/odb-tests/common/include/buildfile b/odb-tests/common/include/buildfile new file mode 100644 index 0000000..6db878c --- /dev/null +++ b/odb-tests/common/include/buildfile @@ -0,0 +1,51 @@ +# file : common/include/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} + +hs = obj1 obj2 obj3 test1 test2 test3 test4 + +exe{driver}: {hxx cxx}{* -*-odb -*-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 + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} 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). Also see driver.cxx for the details on +# the -I options usage. +# +odb_options = --table-prefix include_ \ + "-I$out_base" \ + "-I$src_base/.." \ + "-I$src_base/../.." + +cxx.poptions =+ "-I$out_base" "-I$src_base" \ + "-I$out_base/../.." "-I$src_base/../.." + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/include/driver.cxx b/odb-tests/common/include/driver.cxx new file mode 100644 index 0000000..561746a --- /dev/null +++ b/odb-tests/common/include/driver.cxx @@ -0,0 +1,42 @@ +// file : common/include/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test inclusion of -odb files (compilation test). +// +// The setup of this test is as follows: the ODB compiler has two +// additional include directories in its search path: .. and ../.. +// while the C++ compiler has only ../.. . This way, if a ..-based +// path is used in the generated code, the C++ compilation will +// fail. +// + +#include <memory> +#include <iostream> + +#include <odb/exceptions.hxx> +#include <odb/transaction.hxx> + +#include <libcommon/common.hxx> + +#include "test1.hxx" +#include "test1-odb.hxx" + +#include "test2.hxx" +#include "test2-odb.hxx" + +#include "test3.hxx" +#include "test3-odb.hxx" + +#include "test4.hxx" +#include "test4-odb.hxx" + +#undef NDEBUG +#include <cassert> + +using namespace std; +using namespace odb::core; + +int +main () +{ +} diff --git a/odb-tests/common/include/obj1.hxx b/odb-tests/common/include/obj1.hxx new file mode 100644 index 0000000..33ae0d6 --- /dev/null +++ b/odb-tests/common/include/obj1.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ1_HXX +#define OBJ1_HXX + +#include <odb/core.hxx> + +#pragma db object +struct object1 +{ + object1 (unsigned long id) + : id_ (id) + { + } + + object1 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ1_HXX diff --git a/odb-tests/common/include/obj2.hxx b/odb-tests/common/include/obj2.hxx new file mode 100644 index 0000000..2f20f58 --- /dev/null +++ b/odb-tests/common/include/obj2.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ2_HXX +#define OBJ2_HXX + +#include <odb/core.hxx> + +#pragma db object +struct object2 +{ + object2 (unsigned long id) + : id_ (id) + { + } + + object2 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ2_HXX diff --git a/odb-tests/common/include/obj3.hxx b/odb-tests/common/include/obj3.hxx new file mode 100644 index 0000000..432145b --- /dev/null +++ b/odb-tests/common/include/obj3.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ3_HXX +#define OBJ3_HXX + +#include <odb/core.hxx> + +#pragma db object +struct object3 +{ + object3 (unsigned long id) + : id_ (id) + { + } + + object3 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ3_HXX diff --git a/odb-tests/common/include/objs1.hxx b/odb-tests/common/include/objs1.hxx new file mode 100644 index 0000000..6e949e2 --- /dev/null +++ b/odb-tests/common/include/objs1.hxx @@ -0,0 +1,13 @@ +// file : common/include/objs1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS1_HXX +#define OBJS1_HXX + +#ifdef ODB_COMPILER +# include <include/obj1.hxx> +# include <include/obj2.hxx> +# include <include/obj3.hxx> +#endif + +#endif // OBJS1_HXX diff --git a/odb-tests/common/include/objs2.hxx b/odb-tests/common/include/objs2.hxx new file mode 100644 index 0000000..4f8133b --- /dev/null +++ b/odb-tests/common/include/objs2.hxx @@ -0,0 +1,13 @@ +// file : common/include/objs2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS2_HXX +#define OBJS2_HXX + +#ifdef ODB_COMPILER +# include "include/obj1.hxx" +# include "include/obj2.hxx" +# include "include/obj3.hxx" +#endif + +#endif // OBJS2_HXX diff --git a/odb-tests/common/include/objs3.hxx b/odb-tests/common/include/objs3.hxx new file mode 100644 index 0000000..2f7aaff --- /dev/null +++ b/odb-tests/common/include/objs3.hxx @@ -0,0 +1,11 @@ +// file : common/include/objs3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS3_HXX +#define OBJS3_HXX + +#include "../include/obj1.hxx" +#include "../include/obj2.hxx" +#include "../include/obj3.hxx" + +#endif // OBJS3_HXX diff --git a/odb-tests/common/include/objs4.hxx b/odb-tests/common/include/objs4.hxx new file mode 100644 index 0000000..d766fe6 --- /dev/null +++ b/odb-tests/common/include/objs4.hxx @@ -0,0 +1,11 @@ +// file : common/include/objs1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS4_HXX +#define OBJS4_HXX + +#include <common/include/obj1.hxx> +#include <common/include/obj2.hxx> +#include <common/include/obj3.hxx> + +#endif // OBJS4_HXX diff --git a/odb-tests/common/include/test1.hxx b/odb-tests/common/include/test1.hxx new file mode 100644 index 0000000..1914ddb --- /dev/null +++ b/odb-tests/common/include/test1.hxx @@ -0,0 +1,16 @@ +// file : common/include/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +// Test include directive parsing. +// +#include"obj1.hxx" + + # include \ + <common/include/obj2.hxx> + +/*comment*/ # /*comment*/ include /* comment */ "obj3.hxx" // comment + +#endif // TEST1_HXX diff --git a/odb-tests/common/include/test2.hxx b/odb-tests/common/include/test2.hxx new file mode 100644 index 0000000..6017ac4 --- /dev/null +++ b/odb-tests/common/include/test2.hxx @@ -0,0 +1,15 @@ +// file : common/include/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +// Test preference of includes from the main file. +// +#include "objs1.hxx" + +#include "obj1.hxx" +#include "obj2.hxx" +#include "obj3.hxx" + +#endif // TEST2_HXX diff --git a/odb-tests/common/include/test3.hxx b/odb-tests/common/include/test3.hxx new file mode 100644 index 0000000..e55ecdb --- /dev/null +++ b/odb-tests/common/include/test3.hxx @@ -0,0 +1,12 @@ +// file : common/include/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +// Test preference of longer (more qualified) paths. +// +#include "objs2.hxx" +#include "objs3.hxx" + +#endif // TEST3_HXX diff --git a/odb-tests/common/include/test4.hxx b/odb-tests/common/include/test4.hxx new file mode 100644 index 0000000..b58e679 --- /dev/null +++ b/odb-tests/common/include/test4.hxx @@ -0,0 +1,12 @@ +// file : common/include/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +// Test preference of <> over "". +// +#include "objs2.hxx" +#include "objs4.hxx" + +#endif // TEST3_HXX diff --git a/odb-tests/common/include/testscript b/odb-tests/common/include/testscript new file mode 100644 index 0000000..089f7a1 --- /dev/null +++ b/odb-tests/common/include/testscript @@ -0,0 +1,31 @@ +# file : common/include/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* &!odb-test.db +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $* +} |