Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / test_bestcruisetrack.cpp
blob43fff3e39f09481996dfc61e57939f4a16ec4962
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 "harness_flight.hpp"
24 #include "harness_wind.hpp"
26 static bool
27 test_bestcruisetrack(int test_num, int n_wind)
30 // tests whether following the cruise track which compensates for wind drift
31 // produces routes that are more on track than if the route is allowed to drift
32 // downwind during climbs
34 // this test allows for a small error margin
36 autopilot_parms.enable_bestcruisetrack = false;
37 TestFlightResult result = test_flight(test_num, n_wind);
38 double t0 = result.time_elapsed;
40 autopilot_parms.enable_bestcruisetrack = true;
41 result = test_flight(test_num, n_wind);
42 double t1 = result.time_elapsed;
43 autopilot_parms.enable_bestcruisetrack = false;
45 bool fine = (t1 / t0 < 1.01);
46 ok(fine, GetTestName("faster flying with bestcruisetrack", test_num, n_wind),
47 0);
49 if (!fine || verbose)
50 printf("# time ratio %g\n", t1 / t0);
52 return fine;
55 int
56 main(int argc, char** argv)
58 // default arguments
59 autopilot_parms.SetIdeal();
61 if (!ParseArgs(argc, argv))
62 return 0;
64 unsigned i = rand() % (NUM_WIND - 1) + 1;
65 plan_tests(1);
67 test_bestcruisetrack(1, i);
68 return exit_status();