projects
/
anna.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Suuports clang compiler
[anna.git]
/
test
/
time
/
main.cpp
diff --git
a/test/time/main.cpp
b/test/time/main.cpp
index
6631509
..
c8f9bd8
100644
(file)
--- a/
test/time/main.cpp
+++ b/
test/time/main.cpp
@@
-1,8
+1,8
@@
-// ANNA - Anna is Not
'N'
Anymore
+// ANNA - Anna is Not
Nothingness
Anymore
//
// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
//
//
// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
//
-// http
s://bitbucket.org/testillano/anna
+// http
://redmine.teslayout.com/projects/anna-suite
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
@@
-14,7
+14,7
@@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// *
Neither the name of Google Inc.
nor the names of its
+// *
Neither the name of the copyright holder
nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@
-36,6
+36,7
@@
#define BOOST_TEST_MODULE ANNA_TIME_TEST
#define BOOST_TEST_MODULE ANNA_TIME_TEST
+#include <anna/test/clang_specific.hpp>
#include <boost/test/included/unit_test.hpp>
//#include <iostream>
#include <boost/test/included/unit_test.hpp>
//#include <iostream>
@@
-51,10
+52,9
@@
using namespace anna;
// http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools/reference.html
BOOST_AUTO_TEST_CASE(date) {
// http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools/reference.html
BOOST_AUTO_TEST_CASE(date) {
- const char * tzarg = NULL;
anna::time::functions::initialize();
anna::time::Date current, current2;
anna::time::functions::initialize();
anna::time::Date current, current2;
- current.set
Current
();
+ current.set
Now
();
unsigned int ntptime = current.getNtpTimestamp();
time_t unixtime = current.getUnixTimestamp();
current2.storeNtp(ntptime);
unsigned int ntptime = current.getNtpTimestamp();
time_t unixtime = current.getUnixTimestamp();
current2.storeNtp(ntptime);
@@
-62,25
+62,33
@@
BOOST_AUTO_TEST_CASE(date) {
current2.storeUnix(unixtime);
std::string unixStr = current2.asString();
BOOST_REQUIRE_EQUAL(ntpStr, unixStr);
current2.storeUnix(unixtime);
std::string unixStr = current2.asString();
BOOST_REQUIRE_EQUAL(ntpStr, unixStr);
+
anna::time::Date myBirth("CET"); // 19 December 1974, 10:00 (GMT+1 = UTC + 1 = CET)
anna::time::Date myBirth("CET"); // 19 December 1974, 10:00 (GMT+1 = UTC + 1 = CET)
- //anna::time::Date myBirth; // if Context TZ = shell TZ = "CET"
myBirth.store("19741219101500"); // yyyymmddHHmmss
anna::time::Date same_moment_canary_island("GMT");
same_moment_canary_island.store(myBirth.getUnixTimestamp());
myBirth.store("19741219101500"); // yyyymmddHHmmss
anna::time::Date same_moment_canary_island("GMT");
same_moment_canary_island.store(myBirth.getUnixTimestamp());
- myBirth.setTz
Context
("GMT");
+ myBirth.setTz("GMT");
BOOST_REQUIRE_EQUAL(same_moment_canary_island.yyyymmddHHmmss(), myBirth.yyyymmddHHmmss());
BOOST_REQUIRE_EQUAL(same_moment_canary_island.yyyymmddHHmmss(), myBirth.yyyymmddHHmmss());
+
anna::time::Date birthday("EET");
birthday.store(same_moment_canary_island.getTm(), "GMT"); // TZ origin = "GMT"
anna::time::Date birthday("EET");
birthday.store(same_moment_canary_island.getTm(), "GMT"); // TZ origin = "GMT"
- //BOOST_REQUIRE_EQUAL(birthday, myBirth);
BOOST_REQUIRE_EQUAL(birthday.getUnixTimestamp(), myBirth.getUnixTimestamp());
BOOST_REQUIRE_EQUAL(birthday.getUnixTimestamp(), myBirth.getUnixTimestamp());
- myBirth.setTzContext(anna::time::functions::getLocalTz().getValue().c_str());
- birthday.setTzContext(anna::time::functions::getLocalTz().getValue().c_str()); // Go from "EET" to "CET"
+
+ myBirth.setTz();
+ birthday.setTz();
+ BOOST_REQUIRE_EQUAL(myBirth.asString(), birthday.asString());
BOOST_REQUIRE_EQUAL(myBirth.yyyymmddHHmmss(), birthday.yyyymmddHHmmss());
BOOST_REQUIRE_EQUAL(myBirth.yyyymmddHHmmss(), birthday.yyyymmddHHmmss());
+
+ myBirth.setTz("GMT");
+ BOOST_REQUIRE_EQUAL(myBirth.yyyymmddHHmmss(), "19741219091500");
+
// Adding 18 years to 'myBirth':
// Adding 18 years to 'myBirth':
+ same_moment_canary_island.setTz("CET");
+ anna::time::Date eighteen("CET");
struct tm Tm = myBirth.getTm();
Tm.tm_year += 18;
struct tm Tm = myBirth.getTm();
Tm.tm_year += 18;
- anna::time::Date eighteen("CET");
- eighteen.store(Tm);
+ eighteen.store(Tm, "GMT");
BOOST_REQUIRE(eighteen >= same_moment_canary_island);
BOOST_REQUIRE(eighteen >= same_moment_canary_island);
+ BOOST_REQUIRE_EQUAL(eighteen.yyyymmddHHmmss(), "19921219101500");
}
}