diff --git a/src/modules/locale/Tests.cpp b/src/modules/locale/Tests.cpp index daa585e3d..53cae3fb4 100644 --- a/src/modules/locale/Tests.cpp +++ b/src/modules/locale/Tests.cpp @@ -215,3 +215,49 @@ LocaleTests::testTZLocations() } QCOMPARE( overlapcount, 0 ); } + +const CalamaresUtils::Locale::TZZone* +findZone( const QString& name ) +{ + using namespace CalamaresUtils::Locale; + const CStringPairList& regions = TZRegion::fromZoneTab(); + + for ( const auto* pr : regions ) + { + const TZRegion* region = dynamic_cast< const TZRegion* >( pr ); + if ( !region ) + { + continue; + } + const auto zones = region->zones(); + for ( const auto* pz : zones ) + { + const TZZone* zone = dynamic_cast< const TZZone* >( pz ); + if ( !zone ) + { + continue; + } + + if ( zone->zone() == name ) + { + return zone; + } + } + } + return nullptr; +} + +void +LocaleTests::testSpecificLocations() +{ + const auto* gibraltar = findZone( "Gibraltar" ); + const auto* ceuta = findZone( "Ceuta" ); + QVERIFY( gibraltar ); + QVERIFY( ceuta ); + + auto gpos = TimeZoneImageList::getLocationPosition( gibraltar->longitude(), gibraltar->latitude() ); + auto cpos = TimeZoneImageList::getLocationPosition( ceuta->longitude(), ceuta->latitude() ); + QVERIFY( gpos != cpos ); + QVERIFY( gibraltar->latitude() > ceuta->latitude() ); + QVERIFY( gpos.y() < cpos.y() ); // Gibraltar is north of Ceuta +} diff --git a/src/modules/locale/Tests.h b/src/modules/locale/Tests.h index 20ef86442..e01b1a25c 100644 --- a/src/modules/locale/Tests.h +++ b/src/modules/locale/Tests.h @@ -39,6 +39,7 @@ private Q_SLOTS: // Check the TZ images for consistency void testTZImages(); // No overlaps in images void testTZLocations(); // No overlaps in locations + void testSpecificLocations(); }; #endif