THRIFT-2745: c++ - fixed some unit test compilation on windows
Client: C++-Library
Patch: Sergei Nikulov
unist.h removed
THRIFT_SLEEP_USEC used instead of usleep
ERROR variable renamed to TEST_TOLERANCE
This closes #207
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
index fda6c9e..2d97337 100755
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -24,7 +24,6 @@
#include <thrift/concurrency/Util.h>
#include <assert.h>
-#include <unistd.h>
#include <iostream>
#include <set>
@@ -42,7 +41,7 @@
public:
- static const double ERROR;
+ static const double TEST_TOLERANCE;
class Task: public Runnable {
@@ -279,7 +278,7 @@
error *= 1.0;
}
- bool success = error < ThreadFactoryTests::ERROR;
+ bool success = error < ThreadFactoryTests::TEST_TOLERANCE;
std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << count * timeout << "ms elapsed time: "<< endTime - startTime << "ms error%: " << error * 100.0 << std::endl;
@@ -302,7 +301,7 @@
std::cout << "\t\tthread " << _id << " started" << std::endl;
}
- usleep(1);
+ THRIFT_SLEEP_USEC(1);
}
const size_t _id;
};
@@ -330,7 +329,7 @@
thread->start();
- usleep(1);
+ THRIFT_SLEEP_USEC(1);
} catch (TException& e) {
@@ -349,7 +348,6 @@
}
};
-const double ThreadFactoryTests::ERROR = .20;
+const double ThreadFactoryTests::TEST_TOLERANCE = .20;
}}}} // apache::thrift::concurrency::test
-
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
index 4e53a2d..c08448b 100755
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -33,17 +33,11 @@
using namespace apache::thrift::concurrency;
-/**
- * ThreadManagerTests class
- *
- * @version $Id:$
- */
class ThreadManagerTests {
+ static const double TEST_TOLERANCE;
+
public:
-
- static const double ERROR;
-
class Task: public Runnable {
public:
@@ -190,7 +184,7 @@
error*= -1.0;
}
- bool success = error < ERROR;
+ bool success = error < TEST_TOLERANCE;
std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << expectedTime << "ms elapsed time: "<< time01 - time00 << "ms error%: " << error * 100.0 << std::endl;
@@ -373,9 +367,8 @@
}
};
-const double ThreadManagerTests::ERROR = .20;
+const double ThreadManagerTests::TEST_TOLERANCE = .20;
}}}} // apache::thrift::concurrency
using namespace apache::thrift::concurrency::test;
-
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index 4fe9667..62eb4f4 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -29,17 +29,11 @@
using namespace apache::thrift::concurrency;
-/**
- * ThreadManagerTests class
- *
- * @version $Id:$
- */
class TimerManagerTests {
+ static const double TEST_TOLERANCE;
+
public:
-
- static const double ERROR;
-
class Task: public Runnable {
public:
@@ -65,7 +59,7 @@
float error = delta / _timeout;
- if(error < ERROR) {
+ if(error < TEST_TOLERANCE) {
_success = true;
}
@@ -149,7 +143,6 @@
Monitor _monitor;
};
-const double TimerManagerTests::ERROR = .20;
+const double TimerManagerTests::TEST_TOLERANCE = .20;
}}}} // apache::thrift::concurrency
-