summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/gc/Client.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-09-30 01:36:15 +0000
committerMichi Henning <michi@zeroc.com>2004-09-30 01:36:15 +0000
commitcc66c071a864f5768abea3308c0eade2c5c25b89 (patch)
tree2e2c5b4f5498664c52db2d703260a1b5bc89db59 /cpp/test/Ice/gc/Client.cpp
parentBuild fix (diff)
downloadice-cc66c071a864f5768abea3308c0eade2c5c25b89.tar.bz2
ice-cc66c071a864f5768abea3308c0eade2c5c25b89.tar.xz
ice-cc66c071a864f5768abea3308c0eade2c5c25b89.zip
Added tests for collection of leaf nodes.
Diffstat (limited to 'cpp/test/Ice/gc/Client.cpp')
-rw-r--r--cpp/test/Ice/gc/Client.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/cpp/test/Ice/gc/Client.cpp b/cpp/test/Ice/gc/Client.cpp
index dc7b7ee243a..b4f48cb0fa3 100644
--- a/cpp/test/Ice/gc/Client.cpp
+++ b/cpp/test/Ice/gc/Client.cpp
@@ -48,6 +48,36 @@ struct N2 : public C2
typedef ::IceInternal::Handle<N2> N2Ptr;
+struct NN : public Node
+{
+ NN()
+ {
+ ++num;
+ }
+
+ ~NN()
+ {
+ --num;
+ }
+};
+
+typedef ::IceInternal::Handle<NN> NNPtr;
+
+struct NL : public Leaf
+{
+ NL()
+ {
+ ++num;
+ }
+
+ ~NL()
+ {
+ --num;
+ }
+};
+
+typedef ::IceInternal::Handle<NL> NLPtr;
+
class GarbageProducer : public ::IceUtil::Thread, public ::IceUtil::Monitor< ::IceUtil::Mutex>
{
public:
@@ -471,6 +501,47 @@ MyApplication::run(int argc, char* argv[])
Ice::collectGarbage();
test(num == 0);
cout << "ok" << endl;
+
+ cout << "testing leaf nodes... " << flush;
+
+ {
+ NNPtr nn = new NN;
+ NLPtr nl = new NL;
+ nn->l = nl;
+ nn->n = nn;
+ test(num == 2);
+ Ice::collectGarbage();
+ test(num == 2);
+ }
+ test(num == 2);
+ Ice::collectGarbage();
+ test(num == 0);
+
+ {
+ NNPtr nn1 = new NN;
+ NNPtr nn2 = new NN;
+ NLPtr nl = new NL;
+ nn1->l = nl;
+ nn1->n = nn2;
+ nn2->l = nl;
+ nn2->n = nn1;
+ test(num == 3);
+ Ice::collectGarbage();
+ test(num == 3);
+ }
+ test(num == 3);
+ Ice::collectGarbage();
+ test(num == 0);
+
+ {
+ NLPtr nl = new NL;
+ test(num == 1);
+ }
+ test(num == 0);
+ Ice::collectGarbage();
+ test(num == 0);
+
+ cout << "ok" << endl;
#if defined(_AIX)
cout << "The following test may take a long time (like one full minute); please be patient." << endl;