summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/thread/StartTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceUtil/thread/StartTest.cpp')
-rw-r--r--cpp/test/IceUtil/thread/StartTest.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/cpp/test/IceUtil/thread/StartTest.cpp b/cpp/test/IceUtil/thread/StartTest.cpp
new file mode 100644
index 00000000000..ab5a7712d0d
--- /dev/null
+++ b/cpp/test/IceUtil/thread/StartTest.cpp
@@ -0,0 +1,65 @@
+// **********************************************************************
+//
+// Copyright (c) 2002
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+#include <IceUtil/IceUtil.h>
+
+#include <stdio.h>
+
+#include <StartTest.h>
+#include <TestCommon.h>
+
+using namespace std;
+using namespace IceUtil;
+
+static const string createTestName("thread start");
+
+class StartTestThread : public Thread
+{
+public:
+
+ StartTestThread()
+ {
+ }
+
+ virtual void run()
+ {
+ }
+};
+
+typedef Handle<StartTestThread> StartTestThreadPtr;
+
+StartTest::StartTest() :
+ TestBase(createTestName)
+{
+}
+
+void
+StartTest::run()
+{
+ //
+ // Check that calling start() more than once raises ThreadStartedException.
+ //
+ StartTestThreadPtr t = new StartTestThread();
+ ThreadControl control = t->start();
+ control.join();
+ bool gotException = false;
+ try {
+ t->start();
+ }
+ catch(const ThreadStartedException&)
+ {
+ gotException = true;
+ }
+ test(gotException);
+}