Rework tst_QTimeZone::windowsId() to use initializer-lists
Instead of clearing a list repeatedly to then repopulate it by appending entries. Change-Id: I82594d69c1cb145defff43d84f92f8410d8997aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
83f0796192
commit
46c1936e17
@ -998,46 +998,54 @@ void tst_QTimeZone::windowsId()
|
|||||||
QByteArray("CST6CDT"));
|
QByteArray("CST6CDT"));
|
||||||
QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray());
|
QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray());
|
||||||
|
|
||||||
// No country is sorted list of all zones
|
{
|
||||||
QList<QByteArray> list;
|
// With no country, expect sorted list of all zones for ID
|
||||||
list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City"
|
const QList<QByteArray> list = {
|
||||||
<< "America/Matamoros" << "America/Menominee" << "America/North_Dakota/Beulah"
|
"America/Chicago", "America/Indiana/Knox", "America/Indiana/Tell_City",
|
||||||
<< "America/North_Dakota/Center" << "America/North_Dakota/New_Salem"
|
"America/Matamoros", "America/Menominee", "America/North_Dakota/Beulah",
|
||||||
<< "America/Ojinaga" << "America/Rainy_River" << "America/Rankin_Inlet"
|
"America/North_Dakota/Center", "America/North_Dakota/New_Salem",
|
||||||
<< "America/Resolute" << "America/Winnipeg" << "CST6CDT";
|
"America/Ojinaga", "America/Rainy_River", "America/Rankin_Inlet",
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list);
|
"America/Resolute", "America/Winnipeg", "CST6CDT"
|
||||||
|
};
|
||||||
// Check country with no match returns empty list
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list);
|
||||||
list.clear();
|
}
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::NewZealand),
|
{
|
||||||
list);
|
// Check country with no match returns empty list
|
||||||
|
const QList<QByteArray> empty;
|
||||||
// Check valid country returns list in preference order
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::NewZealand),
|
||||||
list.clear();
|
empty);
|
||||||
list << "America/Winnipeg" << "America/Rainy_River" << "America/Rankin_Inlet"
|
}
|
||||||
<< "America/Resolute";
|
{
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list);
|
// Check valid country returns list in preference order
|
||||||
|
const QList<QByteArray> list = {
|
||||||
list.clear();
|
"America/Winnipeg", "America/Rainy_River", "America/Rankin_Inlet", "America/Resolute"
|
||||||
list << "America/Matamoros" << "America/Ojinaga";
|
};
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list);
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list);
|
||||||
|
}
|
||||||
list.clear();
|
{
|
||||||
list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City"
|
const QList<QByteArray> list = { "America/Matamoros", "America/Ojinaga" };
|
||||||
<< "America/Menominee" << "America/North_Dakota/Beulah" << "America/North_Dakota/Center"
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list);
|
||||||
<< "America/North_Dakota/New_Salem";
|
}
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::UnitedStates),
|
{
|
||||||
list);
|
const QList<QByteArray> list = {
|
||||||
|
"America/Chicago", "America/Indiana/Knox", "America/Indiana/Tell_City",
|
||||||
list.clear();
|
"America/Menominee", "America/North_Dakota/Beulah", "America/North_Dakota/Center",
|
||||||
list << "CST6CDT";
|
"America/North_Dakota/New_Salem"
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyTerritory),
|
};
|
||||||
list);
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::UnitedStates),
|
||||||
|
list);
|
||||||
// Check no windowsId return empty
|
}
|
||||||
list.clear();
|
{
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), list);
|
const QList<QByteArray> list = { "CST6CDT" };
|
||||||
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyTerritory), list);
|
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyTerritory),
|
||||||
|
list);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// Check empty if given no windowsId:
|
||||||
|
const QList<QByteArray> empty;
|
||||||
|
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), empty);
|
||||||
|
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyTerritory), empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTimeZone::isValidId_data()
|
void tst_QTimeZone::isValidId_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user