2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * This file and its contents are supplied under the terms of the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Common Development and Distribution License ("CDDL"), version 1.0.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * You may only use this file in accordance with the terms of version
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * 1.0 of the CDDL.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * A full copy of the text of the CDDL should have accompanied this
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * source. A copy of the CDDL is also available via the Internet at
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * This program tests that newlocale and uselocale work properly in
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * multi-threaded programs. In order for it to work, it requires that
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * some additional locales be installed.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Note that on some platforms, different symbols are used. For example,
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * MacOS Mavericks uses "Eu" for Euro symbol, instead of €. If the locale
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * data changes, then this program will need to update to reflect that.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore for (int i = 0; i < NUMITR; i++) {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore loc = newlocale(LC_ALL_MASK, l->locale, NULL);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "newlocale %s failed", l->locale);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "newlocale data mismatch (%s != %s)",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "C locale day wrong %s != Sunday",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "C cursym mismatch (%s != %s)",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore /* we sleep a random bit to mix it up */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "uselocale data mismatch (%s != %s)",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(lc->currency_symbol, l->cursym) != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_debugf(t, "CSYM: %s", lc->currency_symbol);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore /* we sleep a random bit to mix it up */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "revert old locale mismatch");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "revert GLOBAL_LOCALE mismatch");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_run(NUMTHR, testlocale_thr_one, NULL, "newlocale_threaded");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_ALL_MASK, "de_DE.UTF-8", NULL);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "incorrect Sonntag != %s", day);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore bad = newlocale(LC_ALL_MASK, "cn_US.BIZRRE", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "passed setting bogus locale");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "incorrect Sonntag != %s", day);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_TIME_MASK, "de_DE.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_MESSAGES_MASK, "ru_RU.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_MONETARY_MASK, "en_US.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((day == NULL) || (strcmp(day, "Sonntag") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "day1 mismatch %s != %s", day, "Sonntag");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((yes == NULL) || (strcmp(yes, "да") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((cur == NULL) || (strcmp(cur, "-$") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch [%s] != [%s]", cur, "-$");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore /* order: CTYPE/NUMERIC/TIME/COLLATE/MONETARY/MESSAGES */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore "C/C/de_DE.UTF-8/C/en_US.UTF-8/ru_RU.UTF-8", NULL);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "failed to set composite locale");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((day == NULL) || (strcmp(day, "Sonntag") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "day1 mismatch %s != %s", day, "Sonntag");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((yes == NULL) || (strcmp(yes, "да") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((cur == NULL) || (strcmp(cur, "-$") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch [%s] != [%s]", cur, "-$");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore while ((optc = getopt(argc, argv, "Ddf")) != EOF) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (void) fprintf(stderr, "Usage: %s [-df]\n", argv[0]);