Changeset View
Changeset View
Standalone View
Standalone View
autotests/addresstest.cpp
Show All 26 Lines | |||||
27 | #include <qtest.h> | 27 | #include <qtest.h> | ||
28 | #include <QStandardPaths> | 28 | #include <QStandardPaths> | ||
29 | #include <QFileInfo> | 29 | #include <QFileInfo> | ||
30 | 30 | | |||
31 | QTEST_MAIN(AddressTest) | 31 | QTEST_MAIN(AddressTest) | ||
32 | #ifndef Q_OS_WIN | 32 | #ifndef Q_OS_WIN | ||
33 | void initLocale() | 33 | void initLocale() | ||
34 | { | 34 | { | ||
35 | qputenv("LC_ALL", "en_US.utf-8"); | 35 | qputenv("LC_ALL", "it_CH.utf-8"); | ||
36 | } | 36 | } | ||
37 | 37 | | |||
38 | Q_CONSTRUCTOR_FUNCTION(initLocale) | 38 | Q_CONSTRUCTOR_FUNCTION(initLocale) | ||
39 | #endif | 39 | #endif | ||
40 | 40 | | |||
41 | void AddressTest::initTestCase() | 41 | void AddressTest::initTestCase() | ||
42 | { | 42 | { | ||
43 | } | 43 | } | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 162 | { | |||
209 | 209 | | |||
210 | { | 210 | { | ||
211 | KContacts::Address address; | 211 | KContacts::Address address; | ||
212 | address.setStreet(QStringLiteral("Lummerlandstr. 1")); | 212 | address.setStreet(QStringLiteral("Lummerlandstr. 1")); | ||
213 | address.setPostalCode(QStringLiteral("12345")); | 213 | address.setPostalCode(QStringLiteral("12345")); | ||
214 | address.setLocality(QStringLiteral("Lummerstadt")); | 214 | address.setLocality(QStringLiteral("Lummerstadt")); | ||
215 | address.setCountry(QString()); | 215 | address.setCountry(QString()); | ||
216 | 216 | | |||
217 | const QString result(QStringLiteral("Jim Knopf\nLummerlandstr. 1\nLummerstadt, 12345")); | 217 | const QString result(QStringLiteral("Jim Knopf\nLummerlandstr. 1\n12345 Lummerstadt")); | ||
218 | 218 | | |||
219 | QCOMPARE(address.formattedAddress(QStringLiteral("Jim Knopf")), result); | 219 | QCOMPARE(address.formattedAddress(QStringLiteral("Jim Knopf")), result); | ||
220 | } | 220 | } | ||
221 | | ||||
222 | { | ||||
223 | KContacts::Address address; | ||||
224 | address.setStreet(QStringLiteral("Haus Randa")); | ||||
225 | address.setPostalCode(QStringLiteral("1234")); | ||||
226 | address.setLocality(QStringLiteral("Randa")); | ||||
227 | address.setPostOfficeBox(QStringLiteral("5678")); | ||||
228 | address.setCountry(QStringLiteral("Schweiz")); | ||||
229 | | ||||
230 | // we want the Italian variant of the Swiss format for it_CH | ||||
231 | const QString result(QStringLiteral("Dr. Konqui\nCasella postale 5678\nHaus Randa\n1234 Randa\n\nSCHWEIZ")); | ||||
232 | | ||||
233 | QCOMPARE(address.formattedAddress(QStringLiteral("Dr. Konqui")), result); | ||||
234 | } | ||||
221 | } | 235 | } | ||
222 | 236 | | |||
223 | void AddressTest::shouldExportVcard3() | 237 | void AddressTest::shouldExportVcard3() | ||
224 | { | 238 | { | ||
225 | KContacts::Address address; | 239 | KContacts::Address address; | ||
226 | 240 | | |||
227 | address.setId(QStringLiteral("My Id")); | 241 | address.setId(QStringLiteral("My Id")); | ||
228 | address.setType(KContacts::Address::Home); | 242 | address.setType(KContacts::Address::Home); | ||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |