aboutsummaryrefslogtreecommitdiff
path: root/common/bulk/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-11-24 10:43:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-24 10:43:35 +0200
commit16632e04c20599fd02737f0ad6d8f94d46f038bf (patch)
treef58dc21a1b07045e6f146ff401de55bc4056984b /common/bulk/driver.cxx
parentb9f83d0d666037b7f7728b674362d365470a244a (diff)
Test class templates
Diffstat (limited to 'common/bulk/driver.cxx')
-rw-r--r--common/bulk/driver.cxx91
1 files changed, 90 insertions, 1 deletions
diff --git a/common/bulk/driver.cxx b/common/bulk/driver.cxx
index 4b3b9f8..2903ae4 100644
--- a/common/bulk/driver.cxx
+++ b/common/bulk/driver.cxx
@@ -287,7 +287,7 @@ main (int argc, char* argv[])
#if defined(DATABASE_ORACLE) || defined(DATABASE_MSSQL)
// Test database class API with various forms of containers
- // and elements.
+ // and elements (test #6 is a copy).
//
{
using namespace test1;
@@ -926,6 +926,95 @@ main (int argc, char* argv[])
}
}
+ // Test API with persistent class template instantiations (copy of
+ // test #1).
+ {
+ using namespace test6;
+
+ // Make sure we can still call the non-bulk API.
+ //
+ {
+ object o (0, "z");
+ transaction t (db->begin ());
+ db->persist (o);
+ db->update<object> (o);
+ db->reload<object> (o);
+ db->erase<object> (o);
+ t.commit ();
+ }
+
+
+ // The rest is a copy of test #1.
+ //
+ {
+ object a[2];
+ a[0] = object (1, "a");
+ a[1] = object (2, "b");
+ test (db, a, a + sizeof (a) / sizeof (a[0]));
+ }
+
+ {
+ vector<object> v;
+ v.push_back (object (1, "a"));
+ v.push_back (object (2, "b"));
+ test (db, v.begin (), v.end ());
+ }
+
+ {
+ object o1 (1, "a");
+ object o2 (2, "b");
+ object* a[2] = {&o1, &o2};
+ test (db, a, a + sizeof (a) / sizeof (a[0]));
+ }
+
+ {
+ object o1 (1, "a");
+ object o2 (2, "b");
+ vector<object*> v;
+ v.push_back (&o1);
+ v.push_back (&o2);
+ test (db, v.begin (), v.end ());
+ }
+
+ {
+ auto_ptr<auto_object> a[2];
+ a[0].reset (new auto_object (1, "a"));
+ a[1].reset (new auto_object (2, "b"));
+ test (db, a, a + sizeof (a) / sizeof (a[0]));
+ }
+
+#ifdef HAVE_CXX11
+ {
+ vector<unique_ptr<unique_object>> v;
+ v.push_back (unique_ptr<unique_object> (new unique_object (1, "a")));
+ v.push_back (unique_ptr<unique_object> (new unique_object (2, "b")));
+ test (db, v.begin (), v.end ());
+ }
+#endif
+
+ {
+ vector<object> v;
+ v.push_back (object (1, "a"));
+ v.push_back (object (2, "b"));
+ persist (db, v.begin (), v.end ());
+
+ unsigned long id[2] = {v[0].id, v[1].id};
+ erase_id<object> (db, id, id + sizeof (id) / sizeof (id[0]));
+ }
+
+ {
+ vector<object> v;
+ v.push_back (object (1, "a"));
+ v.push_back (object (2, "b"));
+ persist (db, v.begin (), v.end ());
+
+ vector<unsigned long> id;
+ id.push_back (v[0].id);
+ id.push_back (v[1].id);
+ erase_id<object> (db, id.begin (), id.end ());
+ }
+ }
+
#endif
}
catch (const odb::exception& e)