aboutsummaryrefslogtreecommitdiff
path: root/common/inheritance
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-08 12:22:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-08 12:53:12 +0200
commit261863a5037ba892ec33eb037d77736c8e599369 (patch)
tree9474d4eb6915c32226576081df28c8b3ad8f4a2b /common/inheritance
parentf4131327a7d768689b18dd9cc1c1c64fa6c21d1f (diff)
Test change-tracking container and reuse inheritance
Diffstat (limited to 'common/inheritance')
-rw-r--r--common/inheritance/reuse/driver.cxx54
-rw-r--r--common/inheritance/reuse/test.hxx12
2 files changed, 63 insertions, 3 deletions
diff --git a/common/inheritance/reuse/driver.cxx b/common/inheritance/reuse/driver.cxx
index 78c2703..89a1926 100644
--- a/common/inheritance/reuse/driver.cxx
+++ b/common/inheritance/reuse/driver.cxx
@@ -29,51 +29,73 @@ main (int argc, char* argv[])
base b;
b.comp_.bools.push_back (true);
+ b.comp_.obools.push_back (true);
b.comp_.num = 10;
b.comp_.str = "comp bbb";
b.comp_.nums.push_back (101);
b.comp_.nums.push_back (102);
+ b.comp_.onums.push_back (101);
+ b.comp_.onums.push_back (102);
b.num_ = 0;
b.str_ = "bbb";
b.strs_.push_back ("bbb one");
b.strs_.push_back ("bbb two");
+ b.ostrs_.push_back ("bbb one");
+ b.ostrs_.push_back ("bbb two");
object1 o1;
o1.comp_.bools.push_back (false);
+ o1.comp_.obools.push_back (false);
o1.comp_.num = 11;
o1.comp_.str = "comp o1o1o1";
o1.comp_.nums.push_back (111);
o1.comp_.nums.push_back (112);
+ o1.comp_.onums.push_back (111);
+ o1.comp_.onums.push_back (112);
static_cast<base&> (o1).num_ = 1;
o1.num1_ = 21;
o1.str_ = "base o1o1o1";
o1.strs_.push_back ("base o1o1o1 one");
o1.strs_.push_back ("base o1o1o1 two");
+ o1.ostrs_.push_back ("base o1o1o1 one");
+ o1.ostrs_.push_back ("base o1o1o1 two");
object2 o2;
o2.comp_.bools.push_back (true);
o2.comp_.bools.push_back (false);
+ o2.comp_.obools.push_back (true);
+ o2.comp_.obools.push_back (false);
o2.comp_.num = 12;
o2.comp_.str = "comp o2o2o2";
o2.comp_.nums.push_back (121);
o2.comp_.nums.push_back (122);
+ o2.comp_.onums.push_back (121);
+ o2.comp_.onums.push_back (122);
o2.num_ = 2;
static_cast<base&> (o2).str_ = "base o2o2o2";
o2.str_ = "o2o2o2";
o2.strs_.push_back ("base o2o2o2 one");
o2.strs_.push_back ("base o2o2o2 two");
+ o2.ostrs_.push_back ("base o2o2o2 one");
+ o2.ostrs_.push_back ("base o2o2o2 two");
object3 o3;
o3.comp_.bools.push_back (false);
o3.comp_.bools.push_back (false);
+ o3.comp_.obools.push_back (false);
+ o3.comp_.obools.push_back (false);
o3.comp_.num = 13;
o3.comp_.str = "comp o3o3o3";
o3.comp_.nums.push_back (131);
o3.comp_.nums.push_back (132);
+ o3.comp_.onums.push_back (131);
+ o3.comp_.onums.push_back (132);
o3.num_ = 3;
o3.str_ = "base o3o3o3";
o3.strs_.push_back ("base o3o3o3 one");
o3.strs_.push_back ("base o3o3o3 two");
+ o3.ostrs_.push_back ("base o3o3o3 one");
+ o3.ostrs_.push_back ("base o3o3o3 two");
reference r;
r.o1_ = &o1;
@@ -81,14 +103,20 @@ main (int argc, char* argv[])
empty e;
e.comp_.bools.push_back (true);
e.comp_.bools.push_back (true);
+ e.comp_.obools.push_back (true);
+ e.comp_.obools.push_back (true);
e.comp_.num = 14;
e.comp_.str = "comp eee";
e.comp_.nums.push_back (141);
e.comp_.nums.push_back (142);
+ e.comp_.onums.push_back (141);
+ e.comp_.onums.push_back (142);
e.num_ = 4;
e.str_ = "base eee";
e.strs_.push_back ("base eee one");
e.strs_.push_back ("base eee two");
+ e.ostrs_.push_back ("base eee one");
+ e.ostrs_.push_back ("base eee two");
// persist
//
@@ -125,6 +153,19 @@ main (int argc, char* argv[])
delete lr->o1_;
}
+ // update
+ //
+ {
+ transaction t (db->begin ());
+ db->update (b);
+ db->update (o1);
+ db->update (o2);
+ db->update (o3);
+ db->update (r);
+ db->update (e);
+ t.commit ();
+ }
+
// query
//
{
@@ -173,6 +214,19 @@ main (int argc, char* argv[])
t.commit ();
}
+
+ // erase
+ //
+ {
+ transaction t (db->begin ());
+ db->erase (b);
+ db->erase (o1);
+ db->erase (o2);
+ db->erase (o3);
+ db->erase (r);
+ db->erase (e);
+ t.commit ();
+ }
}
catch (const odb::exception& e)
{
diff --git a/common/inheritance/reuse/test.hxx b/common/inheritance/reuse/test.hxx
index 8222f97..2b566ef 100644
--- a/common/inheritance/reuse/test.hxx
+++ b/common/inheritance/reuse/test.hxx
@@ -9,16 +9,18 @@
#include <vector>
#include <odb/core.hxx>
+#include <odb/vector.hxx>
#pragma db value
struct comp_base
{
std::vector<unsigned char> bools;
+ odb::vector<unsigned char> obools;
bool
operator== (const comp_base& y) const
{
- return bools == y.bools;
+ return bools == y.bools && obools == y.obools;
}
};
@@ -29,6 +31,7 @@ struct comp: comp_base
std::string str;
std::vector<unsigned int> nums;
+ odb::vector<unsigned int> onums;
bool
operator== (const comp& y) const
@@ -37,7 +40,8 @@ struct comp: comp_base
static_cast<const comp_base&> (*this) == y &&
num == y.num &&
str == y.str &&
- nums == y.nums;
+ nums == y.nums &&
+ onums == y.onums;
}
};
@@ -50,6 +54,7 @@ struct abstract_base
std::string str_;
std::vector<std::string> strs_;
+ odb::vector<std::string> ostrs_;
bool
operator== (const abstract_base& y) const
@@ -58,7 +63,8 @@ struct abstract_base
comp_ == y.comp_ &&
num_ == y.num_ &&
str_ == y.str_ &&
- strs_ == y.strs_;
+ strs_ == y.strs_ &&
+ ostrs_ == y.ostrs_;
}
};