knowledgedbtest.cpp 17.6 KB
Newer Older
Volker Krause's avatar
Volker Krause committed
1
/*
2
  SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
Volker Krause's avatar
Volker Krause committed
3

4
   SPDX-License-Identifier: LGPL-2.0-or-later
Volker Krause's avatar
Volker Krause committed
5
6
*/

7
#include <KItinerary/CountryDb>
8

9
#include <knowledgedb/alphaid.h>
10
#include <knowledgedb/trainstationdb.h>
Volker Krause's avatar
Volker Krause committed
11
12
13
14
15
16
17
18
19

#include <QDebug>
#include <QObject>
#include <QTest>
#include <QTimeZone>

using namespace KItinerary;
using namespace KItinerary::KnowledgeDb;

20
21
22
23
24
25
26
27
28
29
30
31
32
namespace KItinerary { namespace KnowledgeDb {
char *toString(Tz tz)
{
    using QTest::toString;
    return toString(tzId(tz));
}
char *toString(CountryId c)
{
    using QTest::toString;
    return toString(c.toString());
}
}}

Volker Krause's avatar
Volker Krause committed
33
34
35
36
class KnowledgeDbTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    void testUnalignedNumber()
    {
        constexpr UnalignedNumber<3> uic1(8001337);
        constexpr UnalignedNumber<3> uic2(8001330);
        static_assert(sizeof(uic1) == 3, "");
        static_assert(alignof(UnalignedNumber<3>) == 1, "");
        QVERIFY(!(uic1 < uic2));
        QVERIFY(uic2 < uic1);
        QVERIFY(uic1 != uic2);
        QVERIFY(!(uic1 == uic2));

        constexpr UnalignedNumber<3> uic3(9899776);
        constexpr UnalignedNumber<3> uic4(1000191);
        QVERIFY(!(uic3 < uic4));
        QVERIFY(uic4 < uic3);
        QVERIFY(uic3 != uic4);
        QVERIFY(!(uic3 == uic4));
        QCOMPARE(uic3.value(), 9899776);
        QCOMPARE(uic4.value(), 1000191);

        constexpr UnalignedNumber<3> uic[2] = { UnalignedNumber<3>(8301700), UnalignedNumber<3>(8301701) };
        static_assert(sizeof(uic) == 6, "");
        QVERIFY(uic[0] < uic[1]);
        QVERIFY(uic[0] == uic[0]);
        QVERIFY(uic[0] != uic[1]);
    }

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
   void testAlphaId()
   {
       using ID3 = AlphaId<uint16_t, 3>;
       constexpr ID3 id1{"ABC"};
       const ID3 id2(QStringLiteral("CBA"));
       static_assert(sizeof(id1) == 2, "");
       QVERIFY(id1.isValid());
       QVERIFY(id2.isValid());
       QVERIFY(id1 < id2);
       QVERIFY(!(id2 < id1));
       QVERIFY(id1 == id1);
       QVERIFY(id1 != id2);
       QVERIFY(!(id1 == id2));
       QVERIFY(!(id1 != id1));

       QCOMPARE(id1.toString(), QLatin1String("ABC"));
       QCOMPARE(id2.toString(), QLatin1String("CBA"));

       constexpr ID3 id3;
       QVERIFY(!id3.isValid());
       QVERIFY(id3.toString().isEmpty());

       qDebug() << id1;
    }

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    void testStationIdentifiers()
    {
        auto sncf = KnowledgeDb::SncfStationId(QStringLiteral("FRPNO"));
        QVERIFY(sncf.isValid());
        QCOMPARE(sncf.toString(), QLatin1String("FRPNO"));
        sncf = KnowledgeDb::SncfStationId(QStringLiteral("Abc"));
        QVERIFY(!sncf.isValid());
        sncf =  KnowledgeDb::SncfStationId(QStringLiteral("CHZID"));
        QVERIFY(sncf.isValid());
        QCOMPARE(sncf.toString(), QLatin1String("CHZID"));

        auto vrCode = KnowledgeDb::VRStationCode(QStringLiteral("HSL"));
        QVERIFY(vrCode.isValid());
        QCOMPARE(vrCode.toString(), QLatin1String("HSL"));
    }

Volker Krause's avatar
Volker Krause committed
105
106
    void testIBNRLookup()
    {
107
        auto station = KnowledgeDb::stationForIbnr(IBNR{1234567});
Volker Krause's avatar
Volker Krause committed
108
        QVERIFY(!station.coordinate.isValid());
109
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
Volker Krause's avatar
Volker Krause committed
110

111
        station = KnowledgeDb::stationForIbnr({});
Volker Krause's avatar
Volker Krause committed
112
        QVERIFY(!station.coordinate.isValid());
113
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
Volker Krause's avatar
Volker Krause committed
114

115
        station = KnowledgeDb::stationForIbnr(IBNR{8011160});
Volker Krause's avatar
Volker Krause committed
116
        QVERIFY(station.coordinate.isValid());
117
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Berlin"));
118
        QCOMPARE(station.country, CountryId{"DE"});
Volker Krause's avatar
Volker Krause committed
119

120
        station = KnowledgeDb::stationForIbnr(IBNR{8501687});
Volker Krause's avatar
Volker Krause committed
121
        QVERIFY(station.coordinate.isValid());
122
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Zurich"));
123
        QCOMPARE(station.country, CountryId{"CH"});
124
125
126
127

        // Aachen West, very close to the NL border, should be in DE timezone
        station = KnowledgeDb::stationForIbnr(IBNR{8000404});
        QVERIFY(station.coordinate.isValid());
128
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Berlin"));
129
        QCOMPARE(station.country, CountryId{"DE"});
Volker Krause's avatar
Volker Krause committed
130
131
    }

132
133
134
135
    void testUICLookup()
    {
        auto station = KnowledgeDb::stationForUic(UICStation{1234567});
        QVERIFY(!station.coordinate.isValid());
136
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
137
138
139

        station = KnowledgeDb::stationForUic({});
        QVERIFY(!station.coordinate.isValid());
140
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
141
142
143

        station = KnowledgeDb::stationForUic(UICStation{1001332});
        QVERIFY(station.coordinate.isValid());
144
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Helsinki"));
145
146
147
        QCOMPARE(station.country, CountryId{"FI"});
    }

148
    void testSncfStationIdLookup()
Volker Krause's avatar
Volker Krause committed
149
    {
150
        auto station = KnowledgeDb::stationForSncfStationId({});
Volker Krause's avatar
Volker Krause committed
151
        QVERIFY(!station.coordinate.isValid());
152
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
Volker Krause's avatar
Volker Krause committed
153

154
        station = KnowledgeDb::stationForSncfStationId(SncfStationId{"XXXXX"});
Volker Krause's avatar
Volker Krause committed
155
        QVERIFY(!station.coordinate.isValid());
156
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
Volker Krause's avatar
Volker Krause committed
157

158
        station = KnowledgeDb::stationForSncfStationId(SncfStationId{"FRAES"});
Volker Krause's avatar
Volker Krause committed
159
        QVERIFY(station.coordinate.isValid());
160
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Paris"));
161
        QCOMPARE(station.country, CountryId{"FR"});
Volker Krause's avatar
Volker Krause committed
162

163
        station = KnowledgeDb::stationForSncfStationId(SncfStationId{QStringLiteral("FRXYT")});
Volker Krause's avatar
Volker Krause committed
164
        QVERIFY(station.coordinate.isValid());
165
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Paris"));
166
        QCOMPARE(station.country, CountryId{"FR"});
Volker Krause's avatar
Volker Krause committed
167

168
        station = KnowledgeDb::stationForSncfStationId(SncfStationId{"CHGVA"});
Volker Krause's avatar
Volker Krause committed
169
        QVERIFY(station.coordinate.isValid());
170
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Zurich"));
171
        QCOMPARE(station.country, CountryId{"CH"});
Volker Krause's avatar
Volker Krause committed
172
173
174
175
        station = KnowledgeDb::stationForSncfStationId(SncfStationId{"FRHWO"}); // alias for CHGVA...
        QVERIFY(station.coordinate.isValid());
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Zurich"));
        QCOMPARE(station.country, CountryId{"CH"});
176
177
178
179
180

        station = KnowledgeDb::stationForSncfStationId(SncfStationId{"NLAMA"}); // vs. SNCB ID of NLASC
        QVERIFY(station.coordinate.isValid());
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Amsterdam"));
        QCOMPARE(station.country, CountryId{"NL"});
Volker Krause's avatar
Volker Krause committed
181
    }
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
    void testBenerailStationIdLookup()
    {
        auto station = KnowledgeDb::stationForBenerailId({});
        QVERIFY(!station.coordinate.isValid());
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());

        station = KnowledgeDb::stationForBenerailId(BenerailStationId{"XXXXX"});
        QVERIFY(!station.coordinate.isValid());
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());

        station = KnowledgeDb::stationForBenerailId(BenerailStationId{"NLASC"});
        QVERIFY(station.coordinate.isValid());
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Amsterdam"));
        QCOMPARE(station.country, CountryId{"NL"});
    }

199
200
201
202
    void testCountryDb()
    {
        auto country = KnowledgeDb::countryForId(CountryId{});
        QCOMPARE(country.drivingSide, KnowledgeDb::DrivingSide::Unknown);
203
        QCOMPARE(country.powerPlugTypes, {Unknown});
204
205
206

        country = KnowledgeDb::countryForId(CountryId{"DE"});
        QCOMPARE(country.drivingSide, KnowledgeDb::DrivingSide::Right);
207
        QCOMPARE(country.powerPlugTypes, {TypeC|TypeF});
208
209
        country = KnowledgeDb::countryForId(CountryId{"GB"});
        QCOMPARE(country.drivingSide, KnowledgeDb::DrivingSide::Left);
210
        QCOMPARE(country.powerPlugTypes, {TypeG});
211
        country = KnowledgeDb::countryForId(CountryId{"GL"});
212
        QCOMPARE(country.drivingSide, KnowledgeDb::DrivingSide::Right);
213
    }
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254

    void testPowerPlugCompat_data()
    {
        using namespace KnowledgeDb;

        QTest::addColumn<PowerPlugTypes>("plugs");
        QTest::addColumn<PowerPlugTypes>("sockets");
        QTest::addColumn<PowerPlugTypes>("failPlugs");
        QTest::addColumn<PowerPlugTypes>("failSockets");

        QTest::newRow("empty") << PowerPlugTypes{} << PowerPlugTypes{} << PowerPlugTypes{} << PowerPlugTypes{};
        QTest::newRow("DE-DE") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{} << PowerPlugTypes{};
        QTest::newRow("DE-CH") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeJ} << PowerPlugTypes{TypeF} << PowerPlugTypes{TypeJ};
        QTest::newRow("CH-DE") << PowerPlugTypes{TypeC|TypeJ} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeJ} << PowerPlugTypes{TypeF};
        QTest::newRow("DE-FR") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeE} << PowerPlugTypes{} << PowerPlugTypes{};
        QTest::newRow("DE-GB") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeG} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeG};
        QTest::newRow("DE-IT") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeF|TypeL} << PowerPlugTypes{} << PowerPlugTypes{TypeL};
        QTest::newRow("IT-DE") << PowerPlugTypes{TypeC|TypeF|TypeL} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeL} << PowerPlugTypes{};
        QTest::newRow("DE-IL") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeH|TypeM} << PowerPlugTypes{TypeF} << PowerPlugTypes{TypeH|TypeM};
        QTest::newRow("DE-AO") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC} << PowerPlugTypes{TypeF} << PowerPlugTypes{};
        QTest::newRow("AO-DE") << PowerPlugTypes{TypeC} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{} << PowerPlugTypes{};
        QTest::newRow("DE-DK") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeE|TypeF|TypeK} << PowerPlugTypes{} << PowerPlugTypes{};
        QTest::newRow("DK-DE") << PowerPlugTypes{TypeC|TypeF|TypeE|TypeK} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeK} << PowerPlugTypes{};
        QTest::newRow("DE-ZA") << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeC|TypeD|TypeM|TypeN} << PowerPlugTypes{TypeF} << PowerPlugTypes{TypeD|TypeM|TypeN};
        QTest::newRow("ZA-CH") << PowerPlugTypes{TypeC|TypeD|TypeM|TypeN} << PowerPlugTypes{TypeC|TypeJ} << PowerPlugTypes{TypeD|TypeM|TypeN} << PowerPlugTypes{TypeJ};
        QTest::newRow("ZA-DE") << PowerPlugTypes{TypeC|TypeD|TypeM|TypeN} << PowerPlugTypes{TypeC|TypeF} << PowerPlugTypes{TypeD|TypeM|TypeN} << PowerPlugTypes{TypeF};
        QTest::newRow("ZA-IT") << PowerPlugTypes{TypeC|TypeD|TypeM|TypeN} << PowerPlugTypes{TypeC|TypeF|TypeL} << PowerPlugTypes{TypeD|TypeM|TypeN} << PowerPlugTypes{TypeF|TypeL};
    }

    void testPowerPlugCompat()
    {
        using namespace KnowledgeDb;

        QFETCH(PowerPlugTypes, plugs);
        QFETCH(PowerPlugTypes, sockets);
        QFETCH(PowerPlugTypes, failPlugs);
        QFETCH(PowerPlugTypes, failSockets);

        QCOMPARE(KnowledgeDb::incompatiblePowerPlugs(plugs, sockets), failPlugs);
        QCOMPARE(KnowledgeDb::incompatiblePowerSockets(plugs, sockets), failSockets);
    }
255
256
257
258
259

    void testTimezoneForCountry()
    {
        using namespace KnowledgeDb;

260
261
262
        QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"DE"})), QTimeZone("Europe/Berlin"));
        QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"FR"})), QTimeZone("Europe/Paris"));
        QCOMPARE(toQTimeZone(timezoneForCountry(CountryId{"BR"})), QTimeZone());
263
    }
264

265
266
267
268
269
270
271
    void testCountryForTimezone()
    {
        using namespace KnowledgeDb;

        QCOMPARE(countryForTimezone(Tz::Europe_Busingen), CountryId{"DE"});
        QCOMPARE(countryForTimezone(Tz::America_Los_Angeles), CountryId{"US"});
        QCOMPARE(countryForTimezone(Tz::Asia_Kuching), CountryId{"MY"});
272
273
        QCOMPARE(countryForTimezone(Tz::Asia_Bangkok), CountryId{});
        QCOMPARE(countryForTimezone(Tz::Asia_Ho_Chi_Minh), CountryId{"VN"});
274
275
    }

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
    void testTimezoneForLocation()
    {
        using namespace KnowledgeDb;

        // basic checks in all quadrants
        QCOMPARE(timezoneForCoordinate(52.4, 13.1), Tz::Europe_Berlin);
        QCOMPARE(timezoneForCoordinate(-8.0, -35.0), Tz::America_Recife);
        QCOMPARE(timezoneForCoordinate(-36.5, 175.0), Tz::Pacific_Auckland);
        QCOMPARE(timezoneForCoordinate(44.0, -79.5), Tz::America_Toronto);

        // Special case: Northern Vietnam has a Thai timezone
        QCOMPARE(timezoneForCoordinate(21.0, 106.0), Tz::Asia_Bangkok);

        // Maastricht (NL), very close to the BE border
        QCOMPARE(timezoneForLocation(50.8505, 5.6881, CountryId{}), Tz::Europe_Amsterdam);
        QCOMPARE(timezoneForLocation(50.8505, 5.6881, CountryId{"NL"}), Tz::Europe_Amsterdam);

        // Aachen, at the BE/DE/NL corner
        QCOMPARE(timezoneForLocation(50.7717, 6.04235, CountryId{}), Tz::Europe_Berlin);
        QCOMPARE(timezoneForLocation(50.7717, 6.04235, CountryId{"DE"}), Tz::Europe_Berlin);
        //QCOMPARE(timezoneForLocation(50.7727, 6.01565, CountryId{}), Tz::Europe_Brussels);
        QCOMPARE(timezoneForLocation(50.7727, 6.01565, CountryId{"BE"}), Tz::Europe_Brussels);

        // Geneva (CH), very close to the FR border
        QCOMPARE(timezoneForLocation(46.23213, 6.10636, CountryId{"CH"}), Tz::Europe_Zurich);

        // Busingen (DE), enclosed by CH, and in theory its own timezone (which we ignore)
        QCOMPARE(timezoneForLocation(47.69947, 8.68833, CountryId{"DE"}), Tz::Europe_Berlin);
        QCOMPARE(timezoneForLocation(47.67904, 8.68813, {}), Tz::Europe_Zurich);

        // Baarle, the ultimate special case, NL/BE differs house by house
        QCOMPARE(timezoneForLocation(51.44344, 4.93373, CountryId{"BE"}), Tz::Europe_Brussels);
        QCOMPARE(timezoneForLocation(51.44344, 4.93373, CountryId{"NL"}), Tz::Europe_Amsterdam);
        bool ambiguous = false;
        auto tz = timezoneForCoordinate(51.44344, 4.93373, &ambiguous);
        QVERIFY(ambiguous);
        QVERIFY(tz == Tz::Europe_Amsterdam || tz == Tz::Europe_Brussels);

        // Eliat Airport (IL), close to JO, and with a minor timezone variation due to different weekends
        QCOMPARE(timezoneForLocation(29.72530, 35.00598, CountryId{"IL"}), Tz::Asia_Jerusalem);
        QCOMPARE(timezoneForLocation(29.60908, 35.02038, CountryId{"JO"}), Tz::Asia_Amman);

        // Tijuana (MX), close to US, tests equivalent tz search in the neighbouring country
        QCOMPARE(timezoneForLocation(32.54274, -116.97505, CountryId{"MX"}), Tz::America_Tijuana);
        QCOMPARE(timezoneForLocation(32.55783, -117.04773, CountryId{"US"}), Tz::America_Los_Angeles);

        // Cordoba (AR), AR has several sub-zones that are all equivalent
        QCOMPARE(timezoneForLocation(-31.4, -64.2, CountryId{"AR"}), Tz::America_Argentina_Cordoba);

        // polar regions
        QCOMPARE(timezoneForCoordinate(-90.0, 0.0), Tz::Undefined);
        QCOMPARE(timezoneForCoordinate(90.0, 0.0), Tz::Undefined);
328
329
330

        // Hong Kong seems problematic on FreeBSD
        QCOMPARE(timezoneForCoordinate(22.31600, 113.93688), Tz::Asia_Hong_Kong);
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
    }

    void testCountryFromCoordinate()
    {
        using namespace KnowledgeDb;

        // basic tests
        QCOMPARE(countryForCoordinate(52.4, 13.1), CountryId{"DE"});
        QCOMPARE(countryForCoordinate(-8.0, -35.0), CountryId{"BR"});
        QCOMPARE(countryForCoordinate(-36.5, 175.0), CountryId{"NZ"});
        QCOMPARE(countryForCoordinate(44.0, -79.5), CountryId{"CA"});

        // ambiguous locations
        QCOMPARE(countryForCoordinate(51.44344, 4.93373), CountryId{});

        // special case: northern Vietnam has a non-VN timezone (not the case anywhere else in the world up to 2020a)
        QCOMPARE(countryForCoordinate(21.0, 106.0), CountryId{});
        QCOMPARE(countryForCoordinate(10.5, 107.0), CountryId{"VN"});
        QCOMPARE(countryForCoordinate(13.7, 100.4), CountryId{});

        // disputed areas
        QCOMPARE(countryForCoordinate(45.0, 34.0), CountryId{});

        // overseas territories with separate ISO 3166-1 codes
        QCOMPARE(countryForCoordinate(4.8, -52.3), CountryId{"GF"}); // could also be "FR"
    }

358
359
360
361
362
363
364
    void testUICCountryCodeLookup()
    {
        using namespace KnowledgeDb;

        QCOMPARE(KnowledgeDb::countryIdForUicCode(80), CountryId{"DE"});
        QCOMPARE(KnowledgeDb::countryIdForUicCode(0), CountryId{});
    }
365
366
367
368
369
370
371
372

    void testIso3Lookup()
    {
        using namespace KnowledgeDb;

        QCOMPARE(KnowledgeDb::countryIdFromIso3166_1alpha3(CountryId3{"ITA"}), CountryId{"IT"});
        QCOMPARE(KnowledgeDb::countryIdFromIso3166_1alpha3(CountryId3{"FOO"}), CountryId{});
    }
373
374
375
376
377

    void testIndianRailwaysStationCodeLookup()
    {
        auto station = KnowledgeDb::stationForIndianRailwaysStationCode(QString());
        QVERIFY(!station.coordinate.isValid());
378
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
379
380
381

        station = KnowledgeDb::stationForIndianRailwaysStationCode(QStringLiteral("NDLS"));
        QVERIFY(station.coordinate.isValid());
382
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Asia/Kolkata"));
383
384
385
386
        QCOMPARE(station.country, CountryId{"IN"});

        station = KnowledgeDb::stationForIndianRailwaysStationCode(QStringLiteral("ndls"));
        QVERIFY(!station.coordinate.isValid());
387
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
388
    }
389
390
391
392
393

    void testFinishStationCodeLookup()
    {
        auto station = KnowledgeDb::stationForVRStationCode(VRStationCode(QStringLiteral("HKI")));
        QVERIFY(station.coordinate.isValid());
394
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone("Europe/Helsinki"));
395
396
397

        station = KnowledgeDb::stationForVRStationCode(VRStationCode(QStringLiteral("BLÄ")));
        QVERIFY(!station.coordinate.isValid());
398
        QCOMPARE(toQTimeZone(station.timezone()), QTimeZone());
399
    }
Volker Krause's avatar
Volker Krause committed
400
401
402
403
404
};

QTEST_APPLESS_MAIN(KnowledgeDbTest)

#include "knowledgedbtest.moc"