Author: zooey Date: 2010-04-07 23:52:28 +0200 (Wed, 07 Apr 2010) New Revision: 36075 Changeset: http://dev.haiku-os.org/changeset/36075/haiku Modified: haiku/branches/developer/zooey/posix-locale/src/tests/system/libroot/posix/locale_test.cpp Log: * add tests for localeconv() invocations for a couple of different locales Modified: haiku/branches/developer/zooey/posix-locale/src/tests/system/libroot/posix/locale_test.cpp =================================================================== --- haiku/branches/developer/zooey/posix-locale/src/tests/system/libroot/posix/locale_test.cpp 2010-04-07 18:52:25 UTC (rev 36074) +++ haiku/branches/developer/zooey/posix-locale/src/tests/system/libroot/posix/locale_test.cpp 2010-04-07 21:52:28 UTC (rev 36075) @@ -8,12 +8,8 @@ #include <stdio.h> -/* - * Test several different aspects of the POSIX locale and the functions - * influenced by it. - */ -int -main(void) +void +test_setlocale() { const char* locales[] = { "POSIX", @@ -41,6 +37,68 @@ } printf("ok (%s)\n", result); } +} + +void +dumpGrouping(const char* grouping) +{ + for (; *grouping; ++grouping) + printf("%d, ", *grouping); + printf("0"); +} + + +void +test_localeconv() +{ + const char* locales[] = { + "POSIX", + "de_DE", + "de_DE.iso8859-1", + "hr_HR.ISO-8859-2", + "de_CH", + "it_IT", + "nl_NL", + "nb_NO", + "POSIX", + NULL + }; + for(int i = 0; locales[i] != NULL; ++i) { + setlocale(LC_ALL, locales[i]); + printf("localeconv for '%s'\n", locales[i]); + struct lconv* lc = localeconv(); + if (!lc) + printf("not ok\n"); + else { + printf("\tlc.decimal_point: '%s'\n", lc->decimal_point); + printf("\tlc.thousands_sep: '%s'\n", lc->thousands_sep); + printf("\tlc.grouping: "); + dumpGrouping(lc->grouping); + printf("\n"); + printf("\tlc.int_curr_symbol: '%s'\n", lc->int_curr_symbol); + printf("\tlc.currency_symbol: '%s'\n", lc->currency_symbol); + printf("\tlc.mon_decimal_point: '%s'\n", lc->mon_decimal_point); + printf("\tlc.mon_thousands_sep: '%s'\n", lc->mon_thousands_sep); + printf("\tlc.mon_grouping: "); + dumpGrouping(lc->mon_grouping); + printf("\n"); + printf("\tlc.positive_sign: '%s'\n", lc->positive_sign); + printf("\tlc.negative_sign: '%s'\n", lc->negative_sign); + } + } +} + + +/* + * Test several different aspects of the POSIX locale and the functions + * influenced by it. + */ +int +main(void) +{ + test_setlocale(); + test_localeconv(); + return 0; }