aboutsummaryrefslogtreecommitdiff
path: root/common/inheritance/polymorphism/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/inheritance/polymorphism/driver.cxx')
-rw-r--r--common/inheritance/polymorphism/driver.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/common/inheritance/polymorphism/driver.cxx b/common/inheritance/polymorphism/driver.cxx
index 7ab6346..672473c 100644
--- a/common/inheritance/polymorphism/driver.cxx
+++ b/common/inheritance/polymorphism/driver.cxx
@@ -29,6 +29,7 @@
#include "test12.hxx"
#include "test13.hxx"
#include "test14.hxx"
+#include "test15.hxx"
#include "test1-odb.hxx"
#include "test2-odb.hxx"
@@ -44,6 +45,7 @@
#include "test12-odb.hxx"
#include "test13-odb.hxx"
#include "test14-odb.hxx"
+#include "test15-odb.hxx"
using namespace std;
using namespace odb::core;
@@ -2002,6 +2004,56 @@ main (int argc, char* argv[])
t.commit ();
}
}
+
+ // Test 15: LOB/long data and polymorphism.
+ //
+ {
+ using namespace test15;
+
+ const char data[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B";
+
+ derived d;
+ d.blob.assign (data, data + sizeof (data));
+
+ // Persist.
+ //
+ {
+ transaction t (db->begin ());
+ base* b (&d);
+ db->persist (b);
+ t.commit ();
+ }
+
+ // Load.
+ //
+ {
+ transaction t (db->begin ());
+ auto_ptr<base> pb (db->load<base> (d.id));
+ t.commit ();
+
+ derived* pd (dynamic_cast<derived*> (pb.get ()));
+ assert (pd != 0 && pd->blob == d.blob);
+ }
+
+ // Query.
+ //
+ {
+ typedef odb::result<base> result;
+
+ transaction t (db->begin ());
+
+ result r (db->query<base> ());
+ result::iterator i (r.begin ()), e (r.end ());
+
+ assert (i != e);
+
+ derived* pd (dynamic_cast<derived*> (&*i));
+ assert (pd != 0 && pd->blob == d.blob);
+
+ assert (++i == e);
+ t.commit ();
+ }
+ }
}
catch (const odb::exception& e)
{