ICUTest: style and output formatting fixes

This commit is contained in:
Adrien Destugues 2014-09-29 14:33:00 +02:00
parent 9d1cbc67a6
commit 27a2d2c7ef

View File

@ -23,9 +23,9 @@ void TestLocale(const Locale& loc)
assert(!loc.isBogus()); assert(!loc.isBogus());
printf("-- basic info\n"); printf("-- basic info\n");
printf("Default locale:\nLanguage: %s\nScript: %s\nVariant: %s\n" printf("Default locale:\nLanguage: %s\nScript: %s\nVariant: %s\n"
"Country: %s\nName: %s\nBaseName: %s\n", loc.getLanguage(), "Country: %s\nName: %s\nBaseName: %s\n", loc.getLanguage(),
loc.getScript(), loc.getVariant(), loc.getScript(), loc.getVariant(),
loc.getCountry(), loc.getName(), loc.getCountry(), loc.getName(),
loc.getBaseName()); loc.getBaseName());
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
@ -36,13 +36,13 @@ void TestLocale(const Locale& loc)
if (keywords == NULL) if (keywords == NULL)
printf("FAILED: getting keywords list returned NULL\n"); printf("FAILED: getting keywords list returned NULL\n");
else { else {
printf("Keywords: %d available\n",keywords->count(err)); printf("Keywords: %d available\n", keywords->count(err));
assert(err == U_ZERO_ERROR); assert(err == U_ZERO_ERROR);
char keyvalue[256]; char keyvalue[256];
while (const char* keyname = keywords->next(NULL,err)) { while (const char* keyname = keywords->next(NULL, err)) {
loc.getKeywordValue(keyname,keyvalue,256,err); loc.getKeywordValue(keyname, keyvalue, 256, err);
printf("%s > %s\n",keyname,keyvalue); printf("%s > %s\n", keyname, keyvalue);
} }
delete keywords; delete keywords;
@ -53,7 +53,7 @@ void TestLocale(const Locale& loc)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
printf("--------\niDefault Locale\n--------\n"); printf("--------\nDefault Locale\n--------\n");
Locale defaultLocale; Locale defaultLocale;
TestLocale(defaultLocale); TestLocale(defaultLocale);
printf("--------\nFrench Locale\n--------\n"); printf("--------\nFrench Locale\n--------\n");
@ -66,18 +66,20 @@ main(int argc, char **argv)
printf("--------\nLocale listing\n--------\n"); printf("--------\nLocale listing\n--------\n");
int32_t count; int32_t count;
const Locale* localeList = Locale::getAvailableLocales(count); const Locale* localeList = Locale::getAvailableLocales(count);
printf("%d locales found\n",count); printf("%d locales found\n", count);
for (int i=0; i<count; i++) { for (int i=0; i<count; i++) {
printf("Locale number %d\n",i); printf("Locale number %d\n", i);
TestLocale(localeList[i]); TestLocale(localeList[i]);
} }
printf("--------\nLocale country codes\n--------\n"); printf("--------\nLocale country codes\n--------\n");
const char* const* countryTable = Locale::getISOCountries(); const char* const* countryTable = Locale::getISOCountries();
for (int i=0; countryTable[i] != NULL; i++) for (int i=0; countryTable[i] != NULL; i++) {
printf("%s\t",countryTable[i]); if (i % 10 == 0) puts("");
printf("%s\t", countryTable[i]);
}
printf("\n--------\nNumberFormat\n--------\n"); printf("\n--------\nNumberFormat\n--------\n");
printf("--------\nDateFormat\n--------\n"); printf("--------\nDateFormat\n--------\n");