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 "Formatter/GeoPointFormatter.hpp"
24 #include "Util/Macros.hpp"
25 #include "Util/StringUtil.hpp"
26 #include "TestUtil.hpp"
29 StringIsEqualWildcard(const TCHAR
*string1
, const TCHAR
*string2
,
30 TCHAR wildcard
= _T('*'))
32 while (*string1
== *string2
||
33 *string1
== wildcard
||
34 *string2
== wildcard
) {
35 if (*string1
== _T('\0') && *string2
== _T('\0'))
45 main(int argc
, char **argv
)
50 GeoPoint
location1(Angle::Degrees(8.466322),
51 Angle::Degrees(49.487153));
53 GeoPoint
location2(Angle::Degrees(-70.011667),
54 Angle::Degrees(-32.653333));
57 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
58 CoordinateFormat::DD_DDDD
);
59 ok1(StringIsEqual(buffer
, _T("49.4872° N 008.4663° E")));
61 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
62 CoordinateFormat::DD_DDDD
);
63 ok1(StringIsEqual(buffer
, _T("32.6533° S 070.0117° W")));
67 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
68 CoordinateFormat::DDMM_MMM
);
69 ok1(StringIsEqual(buffer
, _T("49°29.229' N 008°27.979' E")));
71 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
72 CoordinateFormat::DDMM_MMM
);
73 ok1(StringIsEqual(buffer
, _T("32°39.200' S 070°00.700' W")));
77 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
78 CoordinateFormat::DDMMSS
);
79 ok1(StringIsEqual(buffer
, _T("49°29'14\" N 008°27'59\" E")));
81 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
82 CoordinateFormat::DDMMSS
);
83 ok1(StringIsEqual(buffer
, _T("32°39'12\" S 070°00'42\" W")));
87 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
88 CoordinateFormat::DDMMSS_SS
);
89 ok1(StringIsEqualWildcard(buffer
, _T("49°29'1*.**\" N 008°27'5*.**\" E"),
92 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
93 CoordinateFormat::DDMMSS_SS
);
94 ok1(StringIsEqualWildcard(buffer
, _T("32°39'1*.**\" S 070°00'4*.**\" W"),
98 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
99 CoordinateFormat::UTM
);
100 ok1(StringIsEqualWildcard(buffer
, _T("32U 4613** 5481***")));
102 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
103 CoordinateFormat::UTM
);
104 ok1(StringIsEqualWildcard(buffer
, _T("19H 4051** 6386***")));
107 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
108 CoordinateFormat::DDMMSS
, _T('\n'));
109 ok1(StringIsEqual(buffer
, _T("49°29'14\" N\n008°27'59\" E")));
111 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
112 CoordinateFormat::DDMMSS
, _T('\n'));
113 ok1(StringIsEqual(buffer
, _T("32°39'12\" S\n070°00'42\" W")));
115 FormatGeoPoint(location1
, buffer
, ARRAY_SIZE(buffer
),
116 CoordinateFormat::UTM
, _T('\n'));
117 ok1(StringIsEqualWildcard(buffer
, _T("32U\n4613**\n5481***")));
119 FormatGeoPoint(location2
, buffer
, ARRAY_SIZE(buffer
),
120 CoordinateFormat::UTM
, _T('\n'));
121 ok1(StringIsEqualWildcard(buffer
, _T("19H\n4051**\n6386***")));
124 return exit_status();