TaskStats: remove unused attribute "Time"
[xcsoar.git] / test / src / TestFlatGeoPoint.cpp
blobd2eb2ff7df5d1444981f3909536342e53f33bb43
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 "Geo/Flat/FlatGeoPoint.hpp"
24 #include "TestUtil.hpp"
26 int main(int argc, char **argv)
28 plan_tests(37);
30 FlatGeoPoint p1(1, 1);
31 FlatGeoPoint p2(1, 2);
32 FlatGeoPoint p3(3, 10);
34 // test cross()
35 ok1(p1.CrossProduct(p2) == 1);
36 ok1(p2.CrossProduct(p1) == -1);
37 ok1(p1.CrossProduct(p3) == 7);
38 ok1(p3.CrossProduct(p1) == -7);
39 ok1(p2.CrossProduct(p3) == 4);
40 ok1(p3.CrossProduct(p2) == -4);
42 // test dot()
43 ok1(p1.DotProduct(p2) == 3);
44 ok1(p2.DotProduct(p1) == 3);
45 ok1(p1.DotProduct(p3) == 13);
46 ok1(p3.DotProduct(p1) == 13);
47 ok1(p2.DotProduct(p3) == 23);
48 ok1(p3.DotProduct(p2) == 23);
50 // test ==
51 ok1(p1 == FlatGeoPoint(1, 1));
52 ok1(p2 == FlatGeoPoint(1, 2));
53 ok1(p3 == FlatGeoPoint(3, 10));
55 // test <
56 ok1(p2.Sort(p1));
57 ok1(p3.Sort(p1));
58 ok1(p3.Sort(p2));
60 // test * (and ==)
61 ok1(p1 * fixed(2) == FlatGeoPoint(2, 2));
62 ok1(p2 * fixed(2) == FlatGeoPoint(2, 4));
63 ok1(p3 * fixed(2) == FlatGeoPoint(6, 20));
65 // test +
66 p2 = p2 + p1;
67 ok1(p2.longitude == 2);
68 ok1(p2.latitude == 3);
70 // test -
71 p2 = p2 - p1;
72 ok1(p2.longitude == 1);
73 ok1(p2.latitude == 2);
75 // test distance_sq_to()
76 ok1(p1.DistanceSquared(p2) == 1);
77 ok1(p2.DistanceSquared(p1) == 1);
78 ok1(p1.DistanceSquared(p3) == 85);
79 ok1(p3.DistanceSquared(p1) == 85);
80 ok1(p2.DistanceSquared(p3) == 68);
81 ok1(p3.DistanceSquared(p2) == 68);
83 // test distance_to()
84 ok1(p1.Distance(p2) == 1);
85 ok1(p2.Distance(p1) == 1);
86 ok1(p1.Distance(p3) == 9);
87 ok1(p3.Distance(p1) == 9);
88 ok1(p2.Distance(p3) == 8);
89 ok1(p3.Distance(p2) == 8);
91 return exit_status();