summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/thread/GCSharedTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceUtil/thread/GCSharedTest.cpp')
-rw-r--r--cpp/test/IceUtil/thread/GCSharedTest.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/cpp/test/IceUtil/thread/GCSharedTest.cpp b/cpp/test/IceUtil/thread/GCSharedTest.cpp
new file mode 100644
index 00000000000..73b7cc3c355
--- /dev/null
+++ b/cpp/test/IceUtil/thread/GCSharedTest.cpp
@@ -0,0 +1,50 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceUtil/IceUtil.h>
+
+#include <GCSharedTest.h>
+#include <IceUtil/Thread.h>
+#include <IceUtil/GCShared.h>
+#include <TestCommon.h>
+
+using namespace std;
+using namespace IceUtil;
+
+static const string GCSharedTestName("GCShared");
+
+struct TestClass : public Thread, GCShared
+{
+ virtual void run() {}
+ virtual void __gcReachable(GCObjectMultiSet&) const {}
+ virtual void __gcClear() {}
+
+ bool basesAreVirtual()
+ {
+ GCShared::_noDelete = true;
+ Thread::_noDelete = false;
+ //
+ // If we have virtual bases, there will be only one instance of the IceUtil::Shared base class,
+ // so GCShared::_noDelete will be false after the second assignment.
+ //
+ return !GCShared::_noDelete;
+ }
+};
+
+GCSharedTest::GCSharedTest() :
+ TestBase(GCSharedTestName)
+{
+}
+
+void
+GCSharedTest::run()
+{
+ TestClass tc;
+ test(tc.basesAreVirtual());
+}