test for boost time added. missing configure test for headers yet ...
authorMarc Cromme <marc@indexdata.dk>
Sat, 8 Oct 2005 17:28:28 +0000 (17:28 +0000)
committerMarc Cromme <marc@indexdata.dk>
Sat, 8 Oct 2005 17:28:28 +0000 (17:28 +0000)
needed for throtteling filter which is next move

src/Makefile.am
src/test_boost_time.cpp [new file with mode: 0644]

index 6e72261..042d9d6 100644 (file)
@@ -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 (file)
index 0000000..7c989d9
--- /dev/null
@@ -0,0 +1,71 @@
+#include <iostream>
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+
+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
+ */