Skip to content

Commit

Permalink
Changes: add unit test for the ISO 3166-1 country codes
Browse files Browse the repository at this point in the history
RevBy: Berthold Krevert
  • Loading branch information
Mike FABIAN committed Jan 16, 2012
1 parent be01577 commit 87a0774
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/ut_mlocationdatabase/ut_mlocationdatabase.cpp
Expand Up @@ -430,6 +430,44 @@ void Ut_MLocationDatabase::testCitiesInCountry()
}
}

void Ut_MLocationDatabase::testCountryCodes_data()
{
QTest::addColumn<QString>("countryKey");
QTest::addColumn<QString>("countryCode");

QTest::newRow("Mexico")
<< "qtn_clk_country_mexico"
<< "MX";
}

void Ut_MLocationDatabase::testCountryCodes()
{
QFETCH(QString, countryKey);
QFETCH(QString, countryCode);

MLocationDatabase db;
QList<MCountry> countries = db.countries();

// do only run the tests, if we were able to load
// some countries from the meegotouch-cities-*
// package.
if (countries.count() < 10) {
qWarning( "loading of country list failed, skipping test" );
return;
}
QStringList countryCodes;
foreach (MCountry country, countries) {
QString key = country.key();
QString code = country.countryCode();
qDebug() << "countryKey:" << key << "countryCode:" << code;
QVERIFY2(!code.isEmpty(), "country code should never be empty");
if (key == countryKey)
QCOMPARE(code, countryCode);
country.setCountryCode(QLatin1String("XX"));
QCOMPARE(QLatin1String("XX"), country.countryCode());
}
}

void Ut_MLocationDatabase::testCities_data()
{
QTest::addColumn<QString>("key");
Expand Down
3 changes: 3 additions & 0 deletions tests/ut_mlocationdatabase/ut_mlocationdatabase.h
Expand Up @@ -53,6 +53,9 @@ private slots:
void testCitiesInTimeZone_data();
void testCitiesInTimeZone();

void testCountryCodes_data();
void testCountryCodes();

void dumpCitiesInTimeZoneIds();

void testCities_data();
Expand Down

0 comments on commit 87a0774

Please sign in to comment.