Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / TestUnitsFormatter.cpp
blob271d50deec158d1d5608a51555146b87783e91c0
1 /* Copyright_License {
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/Units.hpp"
24 #include "Units/System.hpp"
25 #include "Units/Units.hpp"
26 #include "Util/Macros.hpp"
27 #include "Util/StringUtil.hpp"
28 #include "Atmosphere/Pressure.hpp"
29 #include "TestUtil.hpp"
31 static void
32 TestAltitude()
34 TCHAR buffer[256];
36 // Test FormatAltitude()
37 FormatAltitude(buffer, fixed(1234), Unit::METER);
38 ok1(StringIsEqual(buffer, _T("1234 m")));
40 FormatAltitude(buffer, Units::ToSysUnit(fixed(1234), Unit::FEET), Unit::FEET);
41 ok1(StringIsEqual(buffer, _T("1234 ft")));
43 FormatAltitude(buffer, fixed(-1234), Unit::METER);
44 ok1(StringIsEqual(buffer, _T("-1234 m")));
46 FormatAltitude(buffer, Units::ToSysUnit(fixed(-1234), Unit::FEET), Unit::FEET);
47 ok1(StringIsEqual(buffer, _T("-1234 ft")));
49 FormatAltitude(buffer, fixed(1234), Unit::METER, false);
50 ok1(StringIsEqual(buffer, _T("1234")));
52 FormatAltitude(buffer, fixed(-1234), Unit::METER, false);
53 ok1(StringIsEqual(buffer, _T("-1234")));
56 static void
57 TestRelativeAltitude()
59 TCHAR buffer[256];
61 // Test FormatRelativeAltitude()
62 FormatRelativeAltitude(buffer, fixed(1234), Unit::METER);
63 ok1(StringIsEqual(buffer, _T("+1234 m")));
65 FormatRelativeAltitude(buffer, Units::ToSysUnit(fixed(1234), Unit::FEET),
66 Unit::FEET);
67 ok1(StringIsEqual(buffer, _T("+1234 ft")));
69 FormatRelativeAltitude(buffer, fixed(-1234), Unit::METER);
70 ok1(StringIsEqual(buffer, _T("-1234 m")));
72 FormatRelativeAltitude(buffer, Units::ToSysUnit(fixed(-1234), Unit::FEET),
73 Unit::FEET);
74 ok1(StringIsEqual(buffer, _T("-1234 ft")));
76 FormatRelativeAltitude(buffer, fixed(1234), Unit::METER, false);
77 ok1(StringIsEqual(buffer, _T("+1234")));
79 FormatRelativeAltitude(buffer, fixed(-1234), Unit::METER, false);
80 ok1(StringIsEqual(buffer, _T("-1234")));
83 static void
84 TestDistance()
86 TCHAR buffer[256];
88 // Test FormatDistance()
89 FormatDistance(buffer, fixed(123.4), Unit::METER);
90 ok1(StringIsEqual(buffer, _T("123 m")));
92 FormatDistance(buffer, fixed(123.4), Unit::METER, false);
93 ok1(StringIsEqual(buffer, _T("123")));
95 FormatDistance(buffer, fixed(123.4), Unit::METER, true, 1);
96 ok1(StringIsEqual(buffer, _T("123.4 m")));
98 FormatDistance(buffer, fixed(123.4), Unit::METER, false, 1);
99 ok1(StringIsEqual(buffer, _T("123.4")));
101 FormatDistance(buffer, fixed(123.4), Unit::METER, true, 2);
102 ok1(StringIsEqual(buffer, _T("123.40 m")));
104 FormatDistance(buffer, fixed(123.4), Unit::METER, false, 2);
105 ok1(StringIsEqual(buffer, _T("123.40")));
107 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::KILOMETER),
108 Unit::KILOMETER);
109 ok1(StringIsEqual(buffer, _T("123 km")));
111 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::KILOMETER),
112 Unit::KILOMETER, false);
113 ok1(StringIsEqual(buffer, _T("123")));
115 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::KILOMETER),
116 Unit::KILOMETER, true, 1);
117 ok1(StringIsEqual(buffer, _T("123.4 km")));
119 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::KILOMETER),
120 Unit::KILOMETER, false, 1);
121 ok1(StringIsEqual(buffer, _T("123.4")));
123 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::NAUTICAL_MILES),
124 Unit::NAUTICAL_MILES);
125 ok1(StringIsEqual(buffer, _T("123 NM")));
127 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::NAUTICAL_MILES),
128 Unit::NAUTICAL_MILES, false);
129 ok1(StringIsEqual(buffer, _T("123")));
131 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::NAUTICAL_MILES),
132 Unit::NAUTICAL_MILES, true, 1);
133 ok1(StringIsEqual(buffer, _T("123.4 NM")));
135 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::NAUTICAL_MILES),
136 Unit::NAUTICAL_MILES, false, 1);
137 ok1(StringIsEqual(buffer, _T("123.4")));
139 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::STATUTE_MILES),
140 Unit::STATUTE_MILES);
141 ok1(StringIsEqual(buffer, _T("123 mi")));
143 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::STATUTE_MILES),
144 Unit::STATUTE_MILES, false);
145 ok1(StringIsEqual(buffer, _T("123")));
147 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::STATUTE_MILES),
148 Unit::STATUTE_MILES, true, 1);
149 ok1(StringIsEqual(buffer, _T("123.4 mi")));
151 FormatDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::STATUTE_MILES),
152 Unit::STATUTE_MILES, false, 1);
153 ok1(StringIsEqual(buffer, _T("123.4")));
156 static void
157 TestSmallDistance()
159 TCHAR buffer[256];
161 // Test FormatSmallDistance()
162 FormatSmallDistance(buffer, fixed(123.4), Unit::METER);
163 ok1(StringIsEqual(buffer, _T("123 m")));
165 FormatSmallDistance(buffer, fixed(123.4), Unit::METER, false);
166 ok1(StringIsEqual(buffer, _T("123")));
168 FormatSmallDistance(buffer, fixed(123.4), Unit::METER, true, 1);
169 ok1(StringIsEqual(buffer, _T("123.4 m")));
171 FormatSmallDistance(buffer, fixed(123.4), Unit::METER, false, 1);
172 ok1(StringIsEqual(buffer, _T("123.4")));
174 FormatSmallDistance(buffer, fixed(123.4), Unit::METER, true, 2);
175 ok1(StringIsEqual(buffer, _T("123.40 m")));
177 FormatSmallDistance(buffer, fixed(123.4), Unit::METER, false, 2);
178 ok1(StringIsEqual(buffer, _T("123.40")));
180 FormatSmallDistance(buffer, fixed(123.4), Unit::KILOMETER);
181 ok1(StringIsEqual(buffer, _T("123 m")));
183 FormatSmallDistance(buffer, fixed(123.4), Unit::KILOMETER, false);
184 ok1(StringIsEqual(buffer, _T("123")));
186 FormatSmallDistance(buffer, fixed(123.4), Unit::KILOMETER, true, 1);
187 ok1(StringIsEqual(buffer, _T("123.4 m")));
189 FormatSmallDistance(buffer, fixed(123.4), Unit::KILOMETER, false, 1);
190 ok1(StringIsEqual(buffer, _T("123.4")));
192 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
193 Unit::NAUTICAL_MILES);
194 ok1(StringIsEqual(buffer, _T("123 ft")));
196 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
197 Unit::NAUTICAL_MILES, false);
198 ok1(StringIsEqual(buffer, _T("123")));
200 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
201 Unit::NAUTICAL_MILES, true, 1);
202 ok1(StringIsEqual(buffer, _T("123.4 ft")));
204 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
205 Unit::NAUTICAL_MILES, false, 1);
206 ok1(StringIsEqual(buffer, _T("123.4")));
208 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
209 Unit::STATUTE_MILES);
210 ok1(StringIsEqual(buffer, _T("123 ft")));
212 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
213 Unit::STATUTE_MILES, false);
214 ok1(StringIsEqual(buffer, _T("123")));
216 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
217 Unit::STATUTE_MILES, true, 1);
218 ok1(StringIsEqual(buffer, _T("123.4 ft")));
220 FormatSmallDistance(buffer, Units::ToSysUnit(fixed(123.4), Unit::FEET),
221 Unit::STATUTE_MILES, false, 1);
222 ok1(StringIsEqual(buffer, _T("123.4")));
225 static void
226 TestDistanceSmart(fixed value, Unit unit, Unit expected_unit,
227 const TCHAR *expected_output_with_unit,
228 const TCHAR *expected_output_without_unit,
229 fixed small_unit_threshold = fixed(2500),
230 fixed precision_threshold = fixed(100))
232 TCHAR buffer[256];
234 ok1(FormatDistanceSmart(buffer, value, unit, true, small_unit_threshold,
235 precision_threshold) == expected_unit);
236 ok1(StringIsEqual(buffer, expected_output_with_unit));
238 ok1(FormatDistanceSmart(buffer, value, unit, false, small_unit_threshold,
239 precision_threshold) == expected_unit);
240 ok1(StringIsEqual(buffer, expected_output_without_unit));
243 static void
244 TestDistanceSmart()
246 // Test FormatDistanceSmart()
248 // Test Meter
249 TestDistanceSmart(fixed(0.1234), Unit::METER, Unit::METER, _T("0.12 m"),
250 _T("0.12"));
252 TestDistanceSmart(fixed(1.234), Unit::METER, Unit::METER, _T("1.23 m"),
253 _T("1.23"));
255 TestDistanceSmart(fixed(12.34), Unit::METER, Unit::METER, _T("12.3 m"),
256 _T("12.3"));
258 TestDistanceSmart(fixed(123.4), Unit::METER, Unit::METER, _T("123 m"),
259 _T("123"));
261 TestDistanceSmart(fixed(1234), Unit::METER, Unit::METER, _T("1234 m"),
262 _T("1234"));
264 TestDistanceSmart(fixed(12345), Unit::METER, Unit::METER, _T("12345 m"),
265 _T("12345"));
267 TestDistanceSmart(fixed(123456), Unit::METER, Unit::METER, _T("123456 m"),
268 _T("123456"));
270 // Test Kilometer
271 TestDistanceSmart(Units::ToSysUnit(fixed(0.1234), Unit::KILOMETER),
272 Unit::KILOMETER, Unit::METER, _T("123 m"), _T("123"));
274 TestDistanceSmart(Units::ToSysUnit(fixed(1.234), Unit::KILOMETER),
275 Unit::KILOMETER, Unit::METER, _T("1234 m"), _T("1234"));
277 TestDistanceSmart(Units::ToSysUnit(fixed(2.345), Unit::KILOMETER),
278 Unit::KILOMETER, Unit::METER, _T("2345 m"), _T("2345"));
280 TestDistanceSmart(Units::ToSysUnit(fixed(2.634), Unit::KILOMETER),
281 Unit::KILOMETER, Unit::KILOMETER, _T("2.63 km"),
282 _T("2.63"));
284 TestDistanceSmart(Units::ToSysUnit(fixed(12.34), Unit::KILOMETER),
285 Unit::KILOMETER, Unit::KILOMETER, _T("12.3 km"),
286 _T("12.3"));
288 TestDistanceSmart(Units::ToSysUnit(fixed(123.4), Unit::KILOMETER),
289 Unit::KILOMETER, Unit::KILOMETER, _T("123 km"), _T("123"));
291 // Test Nautical Miles
292 TestDistanceSmart(Units::ToSysUnit(fixed(123.4), Unit::FEET),
293 Unit::NAUTICAL_MILES, Unit::FEET, _T("123 ft"), _T("123"));
295 TestDistanceSmart(Units::ToSysUnit(fixed(1234), Unit::FEET),
296 Unit::NAUTICAL_MILES, Unit::FEET, _T("1234 ft"),
297 _T("1234"));
299 TestDistanceSmart(Units::ToSysUnit(fixed(2345), Unit::FEET),
300 Unit::NAUTICAL_MILES, Unit::FEET, _T("2345 ft"),
301 _T("2345"));
303 TestDistanceSmart(Units::ToSysUnit(fixed(0.61), Unit::NAUTICAL_MILES),
304 Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("0.61 NM"),
305 _T("0.61"));
307 TestDistanceSmart(Units::ToSysUnit(fixed(1.234), Unit::NAUTICAL_MILES),
308 Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("1.23 NM"),
309 _T("1.23"));
311 TestDistanceSmart(Units::ToSysUnit(fixed(12.34), Unit::NAUTICAL_MILES),
312 Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("12.3 NM"),
313 _T("12.3"));
315 TestDistanceSmart(Units::ToSysUnit(fixed(123.4), Unit::NAUTICAL_MILES),
316 Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("123 NM"),
317 _T("123"));
319 // Test Statute Miles
320 TestDistanceSmart(Units::ToSysUnit(fixed(123.4), Unit::FEET),
321 Unit::STATUTE_MILES, Unit::FEET, _T("123 ft"), _T("123"));
323 TestDistanceSmart(Units::ToSysUnit(fixed(1234), Unit::FEET),
324 Unit::STATUTE_MILES, Unit::FEET, _T("1234 ft"), _T("1234"));
326 TestDistanceSmart(Units::ToSysUnit(fixed(2345), Unit::FEET),
327 Unit::STATUTE_MILES, Unit::FEET, _T("2345 ft"), _T("2345"));
329 TestDistanceSmart(Units::ToSysUnit(fixed(0.71), Unit::STATUTE_MILES),
330 Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("0.71 mi"),
331 _T("0.71"));
333 TestDistanceSmart(Units::ToSysUnit(fixed(1.234), Unit::STATUTE_MILES),
334 Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("1.23 mi"),
335 _T("1.23"));
337 TestDistanceSmart(Units::ToSysUnit(fixed(12.34), Unit::STATUTE_MILES),
338 Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("12.3 mi"),
339 _T("12.3"));
341 TestDistanceSmart(Units::ToSysUnit(fixed(123.4), Unit::STATUTE_MILES),
342 Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("123 mi"),
343 _T("123"));
345 // Test thresholds
346 TestDistanceSmart(Units::ToSysUnit(fixed(0.9), Unit::KILOMETER),
347 Unit::KILOMETER, Unit::METER, _T("900 m"), _T("900"), fixed(1000));
349 TestDistanceSmart(Units::ToSysUnit(fixed(1.1), Unit::KILOMETER),
350 Unit::KILOMETER, Unit::KILOMETER, _T("1.10 km"), _T("1.10"), fixed(1000));
352 TestDistanceSmart(Units::ToSysUnit(fixed(1.1), Unit::KILOMETER),
353 Unit::KILOMETER, Unit::KILOMETER, _T("1.1 km"), _T("1.1"), fixed(1000), fixed(10));
355 TestDistanceSmart(Units::ToSysUnit(fixed(1.1), Unit::KILOMETER),
356 Unit::KILOMETER, Unit::KILOMETER, _T("1 km"), _T("1"), fixed(1000), fixed(1));
360 static void
361 TestSpeed()
363 TCHAR buffer[256];
365 // Test FormatSpeed()
366 FormatSpeed(buffer, fixed(23.46), Unit::METER_PER_SECOND);
367 ok1(StringIsEqual(buffer, _T("23 m/s")));
369 FormatSpeed(buffer, fixed(23.46), Unit::METER_PER_SECOND, true, true);
370 ok1(StringIsEqual(buffer, _T("23.5 m/s")));
372 FormatSpeed(buffer, fixed(23.46), Unit::METER_PER_SECOND, false);
373 ok1(StringIsEqual(buffer, _T("23")));
375 FormatSpeed(buffer, fixed(23.46), Unit::METER_PER_SECOND, false, true);
376 ok1(StringIsEqual(buffer, _T("23.5")));
378 FormatSpeed(buffer, Units::ToSysUnit(fixed(123.43), Unit::KILOMETER_PER_HOUR),
379 Unit::KILOMETER_PER_HOUR);
380 ok1(StringIsEqual(buffer, _T("123 km/h")));
382 FormatSpeed(buffer, Units::ToSysUnit(fixed(123.43), Unit::KILOMETER_PER_HOUR),
383 Unit::KILOMETER_PER_HOUR, true, true);
384 ok1(StringIsEqual(buffer, _T("123 km/h")));
386 FormatSpeed(buffer, Units::ToSysUnit(fixed(83.43), Unit::KILOMETER_PER_HOUR),
387 Unit::KILOMETER_PER_HOUR, true, true);
388 ok1(StringIsEqual(buffer, _T("83.4 km/h")));
390 FormatSpeed(buffer, Units::ToSysUnit(fixed(123.43), Unit::KNOTS),
391 Unit::KNOTS);
392 ok1(StringIsEqual(buffer, _T("123 kt")));
394 FormatSpeed(buffer, Units::ToSysUnit(fixed(123.43), Unit::KNOTS), Unit::KNOTS,
395 true, true);
396 ok1(StringIsEqual(buffer, _T("123 kt")));
398 FormatSpeed(buffer, Units::ToSysUnit(fixed(83.43), Unit::KNOTS), Unit::KNOTS,
399 true, true);
400 ok1(StringIsEqual(buffer, _T("83.4 kt")));
402 FormatSpeed(buffer,
403 Units::ToSysUnit(fixed(123.43), Unit::STATUTE_MILES_PER_HOUR),
404 Unit::STATUTE_MILES_PER_HOUR);
405 ok1(StringIsEqual(buffer, _T("123 mph")));
407 FormatSpeed(buffer,
408 Units::ToSysUnit(fixed(123.43), Unit::STATUTE_MILES_PER_HOUR),
409 Unit::STATUTE_MILES_PER_HOUR, true, true);
410 ok1(StringIsEqual(buffer, _T("123 mph")));
412 FormatSpeed(buffer,
413 Units::ToSysUnit(fixed(83.43), Unit::STATUTE_MILES_PER_HOUR),
414 Unit::STATUTE_MILES_PER_HOUR, true, true);
415 ok1(StringIsEqual(buffer, _T("83.4 mph")));
418 static void
419 TestVerticalSpeed()
421 TCHAR buffer[256];
423 // Test FormatVerticalSpeed()
424 FormatVerticalSpeed(buffer, fixed(1.42), Unit::METER_PER_SECOND);
425 ok1(StringIsEqual(buffer, _T("+1.4 m/s")));
427 FormatVerticalSpeed(buffer, fixed(1.42), Unit::METER_PER_SECOND, false);
428 ok1(StringIsEqual(buffer, _T("+1.4")));
430 FormatVerticalSpeed(buffer, Units::ToSysUnit(fixed(2.47), Unit::KNOTS),
431 Unit::KNOTS);
432 ok1(StringIsEqual(buffer, _T("+2.5 kt")));
434 FormatVerticalSpeed(buffer, Units::ToSysUnit(fixed(2.47), Unit::KNOTS),
435 Unit::KNOTS, false);
436 ok1(StringIsEqual(buffer, _T("+2.5")));
438 FormatVerticalSpeed(buffer,
439 Units::ToSysUnit(fixed(245.4), Unit::FEET_PER_MINUTE),
440 Unit::FEET_PER_MINUTE);
441 ok1(StringIsEqual(buffer, _T("+245 fpm")));
443 FormatVerticalSpeed(buffer,
444 Units::ToSysUnit(fixed(245.4), Unit::FEET_PER_MINUTE),
445 Unit::FEET_PER_MINUTE, false);
446 ok1(StringIsEqual(buffer, _T("+245")));
449 static void
450 TestTemperature()
452 TCHAR buffer[256];
454 // Test FormatTemperature()
455 FormatTemperature(buffer, fixed(293.93), Unit::KELVIN);
456 ok1(StringIsEqual(buffer, _T("294 K")));
458 FormatTemperature(buffer, fixed(293.93), Unit::KELVIN, false);
459 ok1(StringIsEqual(buffer, _T("294")));
461 FormatTemperature(buffer,
462 Units::ToSysUnit(fixed(13.4), Unit::DEGREES_CELCIUS),
463 Unit::DEGREES_CELCIUS);
464 ok1(StringIsEqual(buffer, _T("13 " DEG "C")));
466 FormatTemperature(buffer,
467 Units::ToSysUnit(fixed(13.4), Unit::DEGREES_CELCIUS),
468 Unit::DEGREES_CELCIUS, false);
469 ok1(StringIsEqual(buffer, _T("13")));
471 FormatTemperature(buffer,
472 Units::ToSysUnit(fixed(92.7), Unit::DEGREES_FAHRENHEIT),
473 Unit::DEGREES_FAHRENHEIT);
474 ok1(StringIsEqual(buffer, _T("93 " DEG "F")));
476 FormatTemperature(buffer,
477 Units::ToSysUnit(fixed(92.7), Unit::DEGREES_FAHRENHEIT),
478 Unit::DEGREES_FAHRENHEIT, false);
479 ok1(StringIsEqual(buffer, _T("93")));
482 static void
483 TestPressure()
485 TCHAR buffer[256];
487 // Test FormatPressure()
488 FormatPressure(buffer, AtmosphericPressure::HectoPascal(fixed(1013.25)),
489 Unit::HECTOPASCAL);
490 ok1(StringIsEqual(buffer, _T("1013 hPa")));
492 FormatPressure(buffer, AtmosphericPressure::HectoPascal(fixed(1013.25)),
493 Unit::HECTOPASCAL, false);
494 ok1(StringIsEqual(buffer, _T("1013")));
496 FormatPressure(buffer, AtmosphericPressure::HectoPascal(fixed(1013.25)),
497 Unit::MILLIBAR);
498 ok1(StringIsEqual(buffer, _T("1013 mb")));
500 FormatPressure(buffer, AtmosphericPressure::HectoPascal(fixed(1013.25)),
501 Unit::MILLIBAR, false);
502 ok1(StringIsEqual(buffer, _T("1013")));
504 FormatPressure(buffer, AtmosphericPressure::HectoPascal(
505 Units::ToSysUnit(fixed(103), Unit::TORR)), Unit::TORR);
506 ok1(StringIsEqual(buffer, _T("103 mmHg")));
508 FormatPressure(buffer, AtmosphericPressure::HectoPascal(
509 Units::ToSysUnit(fixed(103), Unit::TORR)), Unit::TORR, false);
510 ok1(StringIsEqual(buffer, _T("103")));
512 FormatPressure(buffer, AtmosphericPressure::HectoPascal(
513 Units::ToSysUnit(fixed(29.92), Unit::INCH_MERCURY)), Unit::INCH_MERCURY);
514 ok1(StringIsEqual(buffer, _T("29.92 inHg")));
516 FormatPressure(buffer, AtmosphericPressure::HectoPascal(
517 Units::ToSysUnit(fixed(29.92), Unit::INCH_MERCURY)),
518 Unit::INCH_MERCURY, false);
519 ok1(StringIsEqual(buffer, _T("29.92")));
523 main(int argc, char **argv)
525 plan_tests(205);
527 TestAltitude();
528 TestRelativeAltitude();
529 TestDistance();
530 TestSmallDistance();
531 TestDistanceSmart();
532 TestSpeed();
533 TestVerticalSpeed();
534 TestTemperature();
535 TestPressure();
537 return exit_status();