3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "Time/RoughTime.hpp"
24 #include "TestUtil.hpp"
26 int main(int argc
, char **argv
)
30 RoughTime a
= RoughTime::Invalid();
35 ok1(a
.GetHour() == 12);
36 ok1(a
.GetMinute() == 1);
37 ok1(a
.GetMinuteOfDay() == 12 * 60 + 1);
39 /* compare a RoughTime with itself */
47 /* compare a RoughTime with another one */
63 /* test RoughTimeSpan::IsInside() */
64 RoughTimeSpan s
= RoughTimeSpan::Invalid();
69 s
= RoughTimeSpan(RoughTime(12, 0), RoughTime::Invalid());
74 s
= RoughTimeSpan(RoughTime::Invalid(), RoughTime(12, 0));
79 s
= RoughTimeSpan(RoughTime(12, 0), RoughTime(12, 1));
84 s
= RoughTimeSpan(RoughTime(12, 0), RoughTime(12, 30));
89 /* test midnight wraparound */
91 b
= RoughTime(23, 59);
108 s
= RoughTimeSpan(RoughTime(23, 0), RoughTime::Invalid());
115 s
= RoughTimeSpan(RoughTime::Invalid(), RoughTime(1, 0));
122 s
= RoughTimeSpan(RoughTime(23, 1), RoughTime(0, 30));
129 /* test operator+(RoughTime, RoughTimeDelta) */
130 ok1(RoughTime(0, 0) + RoughTimeDelta::FromMinutes(0) == RoughTime(0, 0));
131 ok1(RoughTime(0, 0) + RoughTimeDelta::FromMinutes(1) == RoughTime(0, 1));
132 ok1(RoughTime(0, 0) + RoughTimeDelta::FromMinutes(60) == RoughTime(1, 0));
133 ok1(RoughTime(0, 0) + RoughTimeDelta::FromHours(24) == RoughTime(0, 0));
134 ok1(RoughTime(0, 0) + RoughTimeDelta::FromHours(25) == RoughTime(1, 0));
136 ok1(RoughTime(0, 0) - RoughTimeDelta::FromMinutes(0) == RoughTime(0, 0));
137 ok1(RoughTime(0, 0) - RoughTimeDelta::FromMinutes(1) == RoughTime(23, 59));
138 ok1(RoughTime(0, 0) - RoughTimeDelta::FromMinutes(60) == RoughTime(23, 0));
139 ok1(RoughTime(0, 0) - RoughTimeDelta::FromHours(24) == RoughTime(0, 0));
140 ok1(RoughTime(0, 0) - RoughTimeDelta::FromHours(25) == RoughTime(23, 0));
142 return exit_status();