[libcalamares] Test the spot-patch for Johannesburg

- Add a note about notation, degrees-minutes
This commit is contained in:
Adriaan de Groot 2020-08-09 00:20:04 +10:00
parent e35992cf0b
commit 5e5701363c

View File

@ -54,6 +54,7 @@ private Q_SLOTS:
void testTZIterator(); void testTZIterator();
void testLocationLookup_data(); void testLocationLookup_data();
void testLocationLookup(); void testLocationLookup();
void testLocationLookup2();
}; };
LocaleTests::LocaleTests() {} LocaleTests::LocaleTests() {}
@ -423,6 +424,37 @@ LocaleTests::testLocationLookup()
QCOMPARE( zone->zone(), name ); QCOMPARE( zone->zone(), name );
} }
void
LocaleTests::testLocationLookup2()
{
// Official
// ZA -2615+02800 Africa/Johannesburg
// Spot patch
// "ZA -3230+02259 Africa/Johannesburg\n";
const CalamaresUtils::Locale::ZonesModel zones;
const auto* zone = zones.find( -26.15, 28.00 );
QCOMPARE( zone->zone(), QString( "Johannesburg" ) );
// The TZ data sources use minutes-and-seconds notation,
// so "2615" is 26 degrees, 15 minutes, and 15 minutes is
// one-quarter of a degree.
QCOMPARE( zone->latitude(), -26.25 );
QCOMPARE( zone->longitude(), 28.00 );
// Elsewhere in South Africa
const auto* altzone = zones.find( -32.0, 22.0 );
QCOMPARE( altzone, zone ); // same pointer
QCOMPARE( altzone->zone(), QString( "Johannesburg" ) );
QCOMPARE( altzone->latitude(), -26.25 );
QCOMPARE( altzone->longitude(), 28.00 );
altzone = zones.find( -29.0, 27.0 );
QCOMPARE( altzone->zone(), QString( "Maseru" ) );
// -2928, that's -29 and 28/60 of a degree, is almost half, but we don't want
// to fall foul of variations in double-precision
QCOMPARE( trunc( altzone->latitude() * 1000.0 ), -29466 );
}
QTEST_GUILESS_MAIN( LocaleTests ) QTEST_GUILESS_MAIN( LocaleTests )