Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / test / src / TestFlarmNet.cpp
blobe0de0a4ecb3e301235e86baa980388af0146f053
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 "FLARM/FlarmNetDatabase.hpp"
24 #include "FLARM/FlarmNetReader.hpp"
25 #include "FLARM/FlarmNetRecord.hpp"
26 #include "FLARM/FlarmId.hpp"
27 #include "TestUtil.hpp"
29 int main(int argc, char **argv)
31 plan_tests(15);
33 FlarmNetDatabase db;
34 int count = FlarmNetReader::LoadFile(_T("test/data/flarmnet/data.fln"), db);
35 ok1(count == 6);
37 FlarmId id = FlarmId::Parse("DDA85C", NULL);
39 const FlarmNetRecord *record = db.FindRecordById(id);
40 ok1(record != NULL);
42 ok1(_tcscmp(record->id, _T("DDA85C")) == 0);
43 ok1(_tcscmp(record->pilot, _T("Tobias Bieniek")) == 0);
44 ok1(_tcscmp(record->airfield, _T("AACHEN")) == 0);
45 ok1(_tcscmp(record->plane_type, _T("Hornet")) == 0);
46 ok1(_tcscmp(record->registration, _T("D-4449")) == 0);
47 ok1(_tcscmp(record->callsign, _T("TH")) == 0);
48 ok1(_tcscmp(record->frequency, _T("130.625")) == 0);
50 const FlarmNetRecord *array[3];
51 ok1(db.FindRecordsByCallSign(_T("TH"), array, 3) == 2);
53 bool found4449 = false, found5799 = false;
54 for (unsigned i = 0; i < 2; i++) {
55 record = array[i];
56 if (_tcscmp(record->registration, _T("D-4449")) == 0)
57 found4449 = true;
58 if (_tcscmp(record->registration, _T("D-5799")) == 0)
59 found5799 = true;
61 ok1(found4449);
62 ok1(found5799);
64 FlarmId ids[3];
65 ok1(db.FindIdsByCallSign(_T("TH"), ids, 3) == 2);
67 id = FlarmId::Parse("DDA85C", NULL);
68 FlarmId id2 = FlarmId::Parse("DDA896", NULL);
69 bool foundDDA85C = false, foundDDA896 = false;
70 for (unsigned i = 0; i < 2; i++) {
71 if (ids[i] == id)
72 foundDDA85C = true;
73 if (ids[i] == id2)
74 foundDDA896 = true;
76 ok1(foundDDA85C);
77 ok1(foundDDA896);
79 return exit_status();