aboutsummaryrefslogtreecommitdiff
path: root/common/inverse/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-15 13:22:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-15 13:22:36 +0200
commitae6efed243e2ba2a611014707368de6a86d74940 (patch)
treeecca1ff08a83c0c00c8c6b9e0ad73c35fad8df4b /common/inverse/driver.cxx
parent647b604fb0d68d9921e1457ebaaf70a244e22d81 (diff)
Support for inverse on points_to
Diffstat (limited to 'common/inverse/driver.cxx')
-rw-r--r--common/inverse/driver.cxx79
1 files changed, 79 insertions, 0 deletions
diff --git a/common/inverse/driver.cxx b/common/inverse/driver.cxx
index a4a0fc8..ed02509 100644
--- a/common/inverse/driver.cxx
+++ b/common/inverse/driver.cxx
@@ -325,6 +325,85 @@ main (int argc, char* argv[])
}
}
#endif
+
+ // Test inverse based on points_to.
+ //
+ {
+ using namespace test3;
+
+ {
+ obj1 o1 (1, 2);
+ o1.o2 = new obj2;
+
+ {
+ transaction t (db->begin ());
+
+ o1.o2->o1 = db->persist (o1);
+ db->persist (o1.o2);
+
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+
+ auto_ptr<obj1> p (db->load<obj1> (o1.id));
+ assert (p->o2->id == o1.o2->id);
+
+ t.commit ();
+ }
+
+ {
+ typedef odb::query<obj1> query;
+
+ transaction t (db->begin ());
+
+ auto_ptr<obj1> p (db->query_one<obj1> (query::o2->o1.i == o1.id.i &&
+ query::o2->o1.j == o1.id.j));
+ assert (p->o2->id == o1.o2->id);
+
+ t.commit ();
+ }
+ }
+
+ {
+ obj3 o3;
+ o3.o4.push_back (new obj4);
+ o3.o4.push_back (new obj4);
+
+ {
+ transaction t (db->begin ());
+
+ o3.o4[0]->o3 = o3.o4[1]->o3 = db->persist (o3);
+ db->persist (o3.o4[0]);
+ db->persist (o3.o4[1]);
+
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+
+ auto_ptr<obj3> p (db->load<obj3> (o3.id));
+ assert (p->o4[0]->id == o3.o4[0]->id);
+ assert (p->o4[1]->id == o3.o4[1]->id);
+
+ t.commit ();
+ }
+
+ {
+ typedef odb::query<obj3> query;
+
+ transaction t (db->begin ());
+
+ auto_ptr<obj3> p (db->query_one<obj3> (query::id == o3.id));
+ assert (p->o4[0]->id == o3.o4[0]->id);
+ assert (p->o4[1]->id == o3.o4[1]->id);
+
+ t.commit ();
+ }
+ }
+ }
}
catch (const odb::exception& e)
{