[mlpack-svn] r11866 - mlpack/trunk/src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Mar 14 16:24:15 EDT 2012
Author: rcurtin
Date: 2012-03-14 16:24:15 -0400 (Wed, 14 Mar 2012)
New Revision: 11866
Modified:
mlpack/trunk/src/mlpack/tests/cli_test.cpp
Log:
Test multi-run timer functionality.
Modified: mlpack/trunk/src/mlpack/tests/cli_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/cli_test.cpp 2012-03-14 20:23:52 UTC (rev 11865)
+++ mlpack/trunk/src/mlpack/tests/cli_test.cpp 2012-03-14 20:24:15 UTC (rev 11866)
@@ -46,11 +46,11 @@
std::string("True or False")) , 0);
// Check that our aliasing works.
- BOOST_REQUIRE_EQUAL(CLI::HasParam("global/bool"),
+ BOOST_REQUIRE_EQUAL(CLI::HasParam("global/bool"),
CLI::HasParam("alias/bool"));
BOOST_REQUIRE_EQUAL(CLI::GetDescription("global/bool").compare(
CLI::GetDescription("alias/bool")), 0);
- BOOST_REQUIRE_EQUAL(CLI::GetParam<bool>("global/bool"),
+ BOOST_REQUIRE_EQUAL(CLI::GetParam<bool>("global/bool"),
CLI::GetParam<bool>("alias/bool"));
}
@@ -201,4 +201,37 @@
"I have a precise number which is 000156");
}
+/**
+ * We should be able to start and then stop a timer multiple times and it should
+ * save the value.
+ */
+BOOST_AUTO_TEST_CASE(MultiRunTimerTest)
+{
+ Timer::Start("test_timer");
+
+ usleep(10000);
+
+ Timer::Stop("test_timer");
+
+ BOOST_REQUIRE_GT(Timer::Get("test_timer").tv_usec, 10000);
+
+ // Restart it.
+ Timer::Start("test_timer");
+
+ usleep(10000);
+
+ Timer::Stop("test_timer");
+
+ BOOST_REQUIRE_GT(Timer::Get("test_timer").tv_usec, 20000);
+
+ // Just one more time, for good measure...
+ Timer::Start("test_timer");
+
+ usleep(20000);
+
+ Timer::Stop("test_timer");
+
+ BOOST_REQUIRE_GT(Timer::Get("test_timer").tv_usec, 40000);
+}
+
BOOST_AUTO_TEST_SUITE_END();
More information about the mlpack-svn
mailing list