From 5198a65b618d8cacbf3a3852c0299c31a8a7a414 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Sat, 8 Oct 2005 17:28:28 +0000 Subject: [PATCH 1/1] test for boost time added. missing configure test for headers yet ... needed for throtteling filter which is next move --- src/Makefile.am | 6 ++-- src/test_boost_time.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/test_boost_time.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 6e72261..042d9d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.12 2005-10-08 16:32:01 marc Exp $ +## $Id: Makefile.am,v 1.13 2005-10-08 17:28:28 marc Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -10,7 +10,7 @@ YP2_INCHPP = session.hpp package.hpp filter.hpp router.hpp bin_PROGRAMS = check_PROGRAMS = test_filter1 test_filter2 \ test_session1 test_session2 \ - test_thread_pool_observer test_boost_threads + test_thread_pool_observer test_boost_threads test_boost_time noinst_PROGRAMS = p2 TESTS=$(check_PROGRAMS) @@ -20,6 +20,7 @@ test_filter2_SOURCES=test_filter2.cpp $(YP2_INCHPP) test_session1_SOURCES=test_session1.cpp $(YP2_INCHPP) test_session2_SOURCES=test_session2.cpp $(YP2_INCHPP) test_boost_threads_SOURCES=test_boost_threads.cpp +test_boost_time_SOURCES=test_boost_time.cpp test_thread_pool_observer_SOURCES = test_thread_pool_observer.cpp \ thread_pool_observer.cpp thread_pool_observer.h @@ -38,6 +39,7 @@ test_filter2_LDADD = $(LDADD) -lboost_unit_test_framework test_session1_LDADD = $(LDADD) -lboost_unit_test_framework test_session2_LDADD = $(LDADD) -lboost_unit_test_framework test_boost_threads_LDADD = $(LDADD) -lboost_unit_test_framework +test_boost_time_LDADD = $(LDADD) -lboost_unit_test_framework diff --git a/src/test_boost_time.cpp b/src/test_boost_time.cpp new file mode 100644 index 0000000..7c989d9 --- /dev/null +++ b/src/test_boost_time.cpp @@ -0,0 +1,71 @@ +#include + +#include "boost/date_time/posix_time/posix_time.hpp" + +#define BOOST_AUTO_TEST_MAIN +#include + +using namespace boost::unit_test; + + + +BOOST_AUTO_TEST_CASE( testboosttime1 ) +{ + + // test session + try { + + //using namespace boost::posix_time; + //using namespace boost::gregorian; + + //get the current time from the clock -- one second resolution + //boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); + boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); + //std::cout << to_iso_extended_string(now) << std::endl; + //std::cout << now << std::endl; + + sleep(1); + + boost::posix_time::ptime then = boost::posix_time::microsec_clock::local_time(); + + //std::cout << then << std::endl; + + boost::posix_time::time_period period(now, then); + + //std::cout << period << std::endl; + + + //Get the date part out of the time + //date today = now.date(); + //date tommorrow = today + days(1); + //ptime tommorrow_start(tommorrow); //midnight + + //iterator adds by one hour + //time_iterator titr(now,hours(1)); + //for (; titr < tommorrow_start; ++titr) { + // std::cout << to_simple_string(*titr) << std::endl; + //} + + //time_duration remaining = tommorrow_start - now; + //std::cout << "Time left till midnight: " + // << to_simple_string(remaining) << std::endl; + + BOOST_CHECK (1 == 1); + + } + catch (std::exception &e) { + std::cout << e.what() << "\n"; + BOOST_CHECK (false); + } + catch (...) { + BOOST_CHECK (false); + } +} + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ -- 1.7.10.4