TsTimeInstantTZ.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled
4  applications.
5 
6  TerraLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License,
9  or (at your option) any later version.
10 
11  TerraLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with TerraLib. See COPYING. If not, write to
18  TerraLib Team at <terralib-team@terralib.org>.
19  */
20 
23 
24 // Boost
25 #include <boost/algorithm/string/predicate.hpp>
26 #include <boost/date_time/local_time/local_time.hpp>
27 #include <boost/test/unit_test.hpp>
28 
29 BOOST_AUTO_TEST_SUITE(time_instant_tz_test_case)
30 
31 BOOST_AUTO_TEST_CASE(test_ok)
32 {
33  boost::local_time::time_zone_ptr tz_ptr(
34  new boost::local_time::posix_time_zone("UTC"));
35 
36  te::dt::TimeInstantTZ ti_tz(boost::local_time::local_date_time(
37  boost::gregorian::date(2016, boost::gregorian::Dec, 16),
38  boost::posix_time::hours(0), tz_ptr,
39  boost::local_time::local_date_time::NOT_DATE_TIME_ON_ERROR));
40 
41  BOOST_CHECK(ti_tz.toString() != "");
42 }
43 
45 {
46  te::dt::TimeInstantTZ ti_tz(boost::local_time::local_date_time(
47  boost::gregorian::date(2016, boost::gregorian::Dec, 16),
48  boost::posix_time::hours(0), nullptr,
49  boost::local_time::local_date_time::NOT_DATE_TIME_ON_ERROR));
50 
51  BOOST_CHECK(!boost::algorithm::ends_with(ti_tz.toString(), "UTC+00"));
52 }
53 
54 BOOST_AUTO_TEST_CASE(test_special_date)
55 {
56  boost::local_time::time_zone_ptr tz_ptr(
57  new boost::local_time::posix_time_zone("UTC"));
58 
59  te::dt::TimeInstantTZ ti_tz(boost::local_time::local_date_time(
60  boost::posix_time::not_a_date_time, tz_ptr));
61 
62  BOOST_CHECK(ti_tz.toString() == "");
63 }
64 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(test_no_tz)
A class to represent time instant with time zone.
A class to represent time instant with time zone.
Definition: TimeInstantTZ.h:52
std::string toString() const
It returns the time instant with time zone in the ISO textual format (YYYYMMDDThhmmss?hhmm).
An exception class for the DataType module.
BOOST_AUTO_TEST_SUITE(time_instant_tz_test_case) BOOST_AUTO_TEST_CASE(test_ok)