Migrate boost unit test to google test with cmake (ctest)
[anna.git] / test / time / main.cpp
index b5d0d28..8ad07fc 100644 (file)
@@ -6,24 +6,18 @@
 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
 
 
-#define BOOST_TEST_MODULE ANNA_TIME_TEST
-
-#include <anna/test/clang_specific.hpp>
-#include <boost/test/included/unit_test.hpp>
-
-//#include <iostream>
 #include <string>
-
 #include <anna/time/Date.hpp>
 #include <anna/time/functions.hpp>
 
+#include <gtest/gtest.h>
+
 using namespace std;
 using namespace anna;
 
-// see http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools.html
-//     http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools/reference.html
 
-BOOST_AUTO_TEST_CASE(date) {
+TEST(date, Conversions)
+{
   anna::time::functions::initialize();
   anna::time::Date current, current2;
   current.setNow();
@@ -33,26 +27,26 @@ BOOST_AUTO_TEST_CASE(date) {
   std::string ntpStr = current2.asString();
   current2.storeUnix(unixtime);
   std::string unixStr = current2.asString();
-  BOOST_REQUIRE_EQUAL(ntpStr, unixStr);
+  EXPECT_EQ(ntpStr, unixStr);
 
   anna::time::Date myBirth("CET"); // 19 December 1974, 10:00 (GMT+1 = UTC + 1 = CET)
   myBirth.store("19741219101500"); // yyyymmddHHmmss
   anna::time::Date same_moment_canary_island("GMT");
   same_moment_canary_island.store(myBirth.getUnixTimestamp());
   myBirth.setTz("GMT");
-  BOOST_REQUIRE_EQUAL(same_moment_canary_island.yyyymmddHHmmss(), myBirth.yyyymmddHHmmss());
+  EXPECT_EQ(same_moment_canary_island.yyyymmddHHmmss(), myBirth.yyyymmddHHmmss());
 
   anna::time::Date birthday("EET");
   birthday.store(same_moment_canary_island.getTm(), "GMT");  // TZ origin = "GMT"
-  BOOST_REQUIRE_EQUAL(birthday.getUnixTimestamp(), myBirth.getUnixTimestamp());
+  EXPECT_EQ(birthday.getUnixTimestamp(), myBirth.getUnixTimestamp());
 
   myBirth.setTz();
   birthday.setTz();
-  BOOST_REQUIRE_EQUAL(myBirth.asString(), birthday.asString());
-  BOOST_REQUIRE_EQUAL(myBirth.yyyymmddHHmmss(), birthday.yyyymmddHHmmss());
+  EXPECT_EQ(myBirth.asString(), birthday.asString());
+  EXPECT_EQ(myBirth.yyyymmddHHmmss(), birthday.yyyymmddHHmmss());
 
   myBirth.setTz("GMT");
-  BOOST_REQUIRE_EQUAL(myBirth.yyyymmddHHmmss(), "19741219091500");
+  EXPECT_EQ(myBirth.yyyymmddHHmmss(), "19741219091500");
 
   // Adding 18 years to 'myBirth':
   same_moment_canary_island.setTz("CET");
@@ -60,7 +54,15 @@ BOOST_AUTO_TEST_CASE(date) {
   struct tm Tm = myBirth.getTm();
   Tm.tm_year += 18;
   eighteen.store(Tm, "GMT");
-  BOOST_REQUIRE(eighteen >= same_moment_canary_island);
-  BOOST_REQUIRE_EQUAL(eighteen.yyyymmddHHmmss(), "19921219101500");
+  EXPECT_TRUE(eighteen >= same_moment_canary_island);
+  EXPECT_EQ(eighteen.yyyymmddHHmmss(), "19921219101500");
+}
+
+
+
+int main(int argc, char **argv)
+{
+    testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
 }