Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / test_vopt.cpp
blob07123fd7e8f0d994ed1a94eb597eff5179f3f9ad
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_speed_factor(int test_num, int n_wind)
29 // flying at opt speed should be minimum time flight!
31 double te0, te1, te2;
33 TestFlightResult result = test_flight(test_num, n_wind, 1.0);
34 te0 = result.time_elapsed;
36 result = test_flight(test_num, n_wind, 0.7);
37 te1 = result.time_elapsed;
38 // time of this should be higher than nominal
39 ok(te0 < te1, GetTestName("vopt slow or", test_num, n_wind), 0);
41 result = test_flight(test_num, n_wind, 1.5);
42 te2 = result.time_elapsed;
43 // time of this should be higher than nominal
44 ok(te0 < te2, GetTestName("vopt fast or", test_num, n_wind), 0);
46 bool retval = (te0 < te1) && (te0 < te2);
47 if (verbose || !retval) {
48 printf("# sf 0.8 time_elapsed_rat %g\n", te1 / te0);
49 printf("# sf 1.2 time_elapsed_rat %g\n", te2 / te0);
51 return retval;
54 int
55 main(int argc, char** argv)
57 // default arguments
58 autopilot_parms.SetIdeal();
60 if (!ParseArgs(argc, argv))
61 return 0;
63 unsigned i = rand() % NUM_WIND;
64 plan_tests(2);
66 // tests whether flying at VOpt for OR task is optimal
67 test_speed_factor(3, i);
68 return exit_status();