aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-09-18 23:35:12 +0200
committerSebastian Geerken <devnull@localhost>2014-09-18 23:35:12 +0200
commitcd928dc6b7beb9faa3717b8b24eea4e5f714a954 (patch)
treed16dc2c05dfc32aa12e3f8bb869126b205c4c11a
parent11a3b3104e4818e6332b0ce0e9dbbfdf7fa93e71 (diff)
Updated test.
-rw-r--r--test/identity.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/identity.cc b/test/identity.cc
index ea1f4603..a1a136eb 100644
--- a/test/identity.cc
+++ b/test/identity.cc
@@ -1,9 +1,13 @@
/*
* This small program tests how IdentifiableObject works with multiple
* inheritance ("diamond" inheritance, more precisely, since all
- * classes have there root in IdentifiableObject.) With virtual
- * superclasses, this example works actually (for comprehensible
- * reasons), but I'm not sure about more compex class hierarchies.
+ * classes have there root in IdentifiableObject.)
+ *
+ * Current status: With virtual superclasses, you get a class
+ * hierarchie "root -> A -> B -> C", so that the first part of this
+ * example works actually (C is a subclass of A and of B), but the
+ * second fails (it should print "false", but it is erroneously
+ * assumed that B is a subclass of A.)
*/
#include "../lout/identity.hh"
@@ -35,11 +39,17 @@ int A::CLASS_ID = -1, B::CLASS_ID = -1, C::CLASS_ID = -1;
int main (int argc, char *argv[])
{
+ printf ("A: %d, B: %d, C: %d\n", A::CLASS_ID, B::CLASS_ID, C::CLASS_ID);
+
C x;
assert (x.instanceOf (A::CLASS_ID));
assert (x.instanceOf (B::CLASS_ID));
assert (x.instanceOf (C::CLASS_ID));
- printf ("A: %d, B: %d, C: %d, x: %d\n",
- A::CLASS_ID, B::CLASS_ID, C::CLASS_ID, x.getClassId ());
+ printf ("x: %d\n", x.getClassId ());
+
+ B y;
+ printf ("y: %d; instance of A: %s\n",
+ y.getClassId (), y.instanceOf (B::CLASS_ID) ? "true" : "false");
+
return 0;
}