summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Blum2013-06-11 11:41:38 -0700
committerJosh Blum2013-06-11 11:41:38 -0700
commit04b91dfbf973404cf69a78d18e2f42906c51152d (patch)
treedb2ab852420eb540574e41b8abedb79af819c07f /tests
parent39b7a04a8ddac19fa694abdb963e861dc6adeee2 (diff)
downloadsandhi-04b91dfbf973404cf69a78d18e2f42906c51152d.tar.gz
sandhi-04b91dfbf973404cf69a78d18e2f42906c51152d.tar.bz2
sandhi-04b91dfbf973404cf69a78d18e2f42906c51152d.zip
gras: added test for timer stuff
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/chrono_time_test.cpp23
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 797f858..761239e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,6 +14,7 @@ if (NOT Boost_FOUND)
endif()
set(test_sources
+ chrono_time_test.cpp
block_props_test.cpp
serialize_tags_test.cpp
)
diff --git a/tests/chrono_time_test.cpp b/tests/chrono_time_test.cpp
new file mode 100644
index 0000000..80c80ab
--- /dev/null
+++ b/tests/chrono_time_test.cpp
@@ -0,0 +1,23 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#include <boost/test/unit_test.hpp>
+#include <iostream>
+
+#include <gras/chrono.hpp>
+#include <boost/thread/thread.hpp> //sleep
+
+BOOST_AUTO_TEST_CASE(test_chrono_time)
+{
+ gras::time_ticks_t t0 = gras::time_now();
+ boost::this_thread::sleep(boost::posix_time::seconds(1));
+ gras::time_ticks_t t1 = gras::time_now();
+
+ std::cout << "t0 " << t0 << std::endl;
+ std::cout << "t1 " << t1 << std::endl;
+ BOOST_CHECK(t1 > t0);
+
+ const double delta_time = double(t1-t0)/gras::time_tps();
+ std::cout << "delta_time " << delta_time << std::endl;
+ //this check allows +/- 0.5 seconds -- so it should always pass
+ BOOST_CHECK(delta_time < 1.5 and delta_time > 0.5);
+}