aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-28 09:54:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-28 09:54:19 +0200
commite61fb61f6406db4d1b3b33eb72007ba22efb44bd (patch)
tree0dff61043ebda523eff7451b8f210d395ef4b9f0 /common
parent3de8e4843bc85f9fc6e63c1a4fea6b57ff0351b6 (diff)
Recode tests to work with implementations lacking result::size()
Diffstat (limited to 'common')
-rw-r--r--common/composite/driver.cxx6
-rw-r--r--common/const/driver.cxx12
-rw-r--r--common/ctor/driver.cxx15
-rw-r--r--common/inverse/driver.cxx9
-rw-r--r--common/query/driver.cxx6
-rw-r--r--common/relationship/driver.cxx3
6 files changed, 30 insertions, 21 deletions
diff --git a/common/composite/driver.cxx b/common/composite/driver.cxx
index 51e6a26..e1dfef8 100644
--- a/common/composite/driver.cxx
+++ b/common/composite/driver.cxx
@@ -92,8 +92,9 @@ main (int argc, char* argv[])
result r (db->query<person> (query::name::first == "Joe"));
- assert (r.size () == 1);
+ assert (!r.empty ());
assert (*r.begin () == p);
+ assert (size (r) == 1);
t.commit ();
}
@@ -105,8 +106,9 @@ main (int argc, char* argv[])
result r (db->query<person> (query::name::flags::alias));
- assert (r.size () == 1);
+ assert (!r.empty ());
assert (*r.begin () == p);
+ assert (size (r) == 1);
t.commit ();
}
diff --git a/common/const/driver.cxx b/common/const/driver.cxx
index 10e3103..17c2edc 100644
--- a/common/const/driver.cxx
+++ b/common/const/driver.cxx
@@ -122,8 +122,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
result1 r1 (db->query<const obj1> (query1::id < 3));
-
- assert (r1.size () == 2);
+ size_t n1 (0);
for (result1::iterator i (r1.begin ()); i != r1.end (); ++i)
{
@@ -134,11 +133,13 @@ main (int argc, char* argv[])
i.load (o);
assert (p->id == o.id);
delete p;
+ n1++;
}
- result2 r2 (db->query<const obj2> (query2::id < 3));
+ assert (n1 == 2);
- assert (r2.size () == 2);
+ result2 r2 (db->query<const obj2> (query2::id < 3));
+ size_t n2 (0);
for (result2::iterator i (r2.begin ()); i != r2.end (); ++i)
{
@@ -148,8 +149,11 @@ main (int argc, char* argv[])
obj2 o (0);
i.load (o);
assert (p->id == o.id);
+ n2++;
}
+ assert (n2 == 2);
+
t.commit ();
}
diff --git a/common/ctor/driver.cxx b/common/ctor/driver.cxx
index 23d2af1..a83724c 100644
--- a/common/ctor/driver.cxx
+++ b/common/ctor/driver.cxx
@@ -58,16 +58,15 @@ main (int argc, char* argv[])
result r (db->query<person> (query::age < 30));
- assert (r.size () == 1);
+ assert (!r.empty ());
- for (result::iterator i (r.begin ()); i != r.end (); ++i)
- {
- i.load (p);
+ result::iterator i (r.begin ());
+ i.load (p);
+ assert (p.first_ == "Jane");
+ assert (p.last_ == "Doe");
+ assert (p.age_ == 29);
- assert (p.first_ == "Jane");
- assert (p.last_ == "Doe");
- assert (p.age_ == 29);
- }
+ assert (size (r) == 1);
t.commit ();
}
diff --git a/common/inverse/driver.cxx b/common/inverse/driver.cxx
index 1f018e7..c07b751 100644
--- a/common/inverse/driver.cxx
+++ b/common/inverse/driver.cxx
@@ -173,9 +173,10 @@ main (int argc, char* argv[])
transaction t (db->begin ());
result r (db->query<obj2> (query::o1::id == "obj1 1"));
- assert (r.size () == 1);
+ assert (!r.empty ());
assert (r.begin ()->id == o2->id);
assert (r.begin ()->o1->id == o1_1->id);
+ assert (size (r) == 1);
t.commit ();
}
@@ -190,15 +191,17 @@ main (int argc, char* argv[])
transaction t (db->begin ());
result r (db->query<obj3> (query::o1::id == "obj1 1"));
-
- assert (r.size () == 2);
+ size_t n (0);
for (result::iterator i (r.begin ()); i != r.end (); ++i)
{
assert (i->id == o3_1->id || i->id == o3_2->id);
assert (i->o1->id == o1_1->id);
+ n++;
}
+ assert (n == 2);
+
t.commit ();
}
diff --git a/common/query/driver.cxx b/common/query/driver.cxx
index 9d948cc..2f97f2e 100644
--- a/common/query/driver.cxx
+++ b/common/query/driver.cxx
@@ -392,10 +392,10 @@ main (int argc, char* argv[])
transaction t (db->begin ());
result r (db->query<person> (query::last_name == "Doe"));
- assert (r.size () == 2);
-
result::iterator i (r.begin ());
- i++;
+ assert (i != r.end ());
+ ++i;
+ assert (i != r.end ());
auto_ptr<person> joe (db->load<person> (3));
assert (i->last_name_ == "Doe");
diff --git a/common/relationship/driver.cxx b/common/relationship/driver.cxx
index cad17a0..abbae29 100644
--- a/common/relationship/driver.cxx
+++ b/common/relationship/driver.cxx
@@ -105,8 +105,9 @@ main (int argc, char* argv[])
transaction t (db->begin ());
result r (db->query<aggr> (query::o1::str == "obj1"));
- assert (r.size () == 1);
+ assert (!r.empty ());
assert (r.begin ()->o1->id == a.o1->id);
+ assert (size (r) == 1);
t.commit ();
}