Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-28 07:34:40 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-28 07:34:40 +0400
commitb99ebb7a19d50b75e07ce5a2622608e9cee52ef5 (patch)
tree1a1a4ce707fd51dcb3db09ec46b846d1d9871d15 /mert/TimerTest.cpp
parentba987c94ba9be5e7c8eb9c3e7c83d8f971fbd3aa (diff)
Fix failure of the Timer unit test.
Diffstat (limited to 'mert/TimerTest.cpp')
-rw-r--r--mert/TimerTest.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/mert/TimerTest.cpp b/mert/TimerTest.cpp
index 04ec75dfa..15e6891e4 100644
--- a/mert/TimerTest.cpp
+++ b/mert/TimerTest.cpp
@@ -5,23 +5,28 @@
#include <string>
#include <iostream>
+#include <unistd.h>
BOOST_AUTO_TEST_CASE(timer_basic_test) {
Timer timer;
+ const int sleep_time_microsec = 40; // ad-hoc microseconds to pass unit tests.
+
timer.start();
BOOST_REQUIRE(timer.is_running());
- BOOST_REQUIRE(timer.get_elapsed_cpu_time() > 0.0);
- BOOST_REQUIRE(timer.get_elapsed_cpu_time_microseconds() > 0);
- BOOST_REQUIRE(timer.get_elapsed_wall_time() > 0.0);
- BOOST_REQUIRE(timer.get_elapsed_wall_time_microseconds() > 0);
+ BOOST_REQUIRE(usleep(sleep_time_microsec) == 0);
+ BOOST_CHECK(timer.get_elapsed_cpu_time() > 0.0);
+ BOOST_CHECK(timer.get_elapsed_cpu_time_microseconds() > 0);
+ BOOST_CHECK(timer.get_elapsed_wall_time() > 0.0);
+ BOOST_CHECK(timer.get_elapsed_wall_time_microseconds() > 0);
timer.restart();
BOOST_REQUIRE(timer.is_running());
- BOOST_REQUIRE(timer.get_elapsed_cpu_time() > 0.0);
- BOOST_REQUIRE(timer.get_elapsed_cpu_time_microseconds() > 0);
- BOOST_REQUIRE(timer.get_elapsed_wall_time() > 0.0);
- BOOST_REQUIRE(timer.get_elapsed_wall_time_microseconds() > 0);
+ BOOST_REQUIRE(usleep(sleep_time_microsec) == 0);
+ BOOST_CHECK(timer.get_elapsed_cpu_time() > 0.0);
+ BOOST_CHECK(timer.get_elapsed_cpu_time_microseconds() > 0);
+ BOOST_CHECK(timer.get_elapsed_wall_time() > 0.0);
+ BOOST_CHECK(timer.get_elapsed_wall_time_microseconds() > 0);
const std::string s = timer.ToString();
- BOOST_REQUIRE(!s.empty());
+ BOOST_CHECK(!s.empty());
}