538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * This file and its contents are supplied under the terms of the
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Common Development and Distribution License ("CDDL"), version 1.0.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * You may only use this file in accordance with the terms of version
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * 1.0 of the CDDL.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * A full copy of the text of the CDDL should have accompanied this
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * source. A copy of the CDDL is also available via the Internet at
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * This program tests that newlocale and uselocale work properly in
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * multi-threaded programs. In order for it to work, it requires that
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * some additional locales be installed.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Note that on some platforms, different symbols are used. For example,
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * MacOS Mavericks uses "Eu" for Euro symbol, instead of €. If the locale
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * data changes, then this program will need to update to reflect that.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Note also that this file is easiest edited with a UTF-8 capable editor,
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * as there are embedded UTF-8 symbols in some of the strings.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amorestruct langinfo_test en_gb_latin15_data[] = {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore { YESEXPR, "^(([дД]([аА])?)|([yY]([eE][sS])?))" },
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore { NOEXPR, "^(([нН]([еЕ][тТ])?)|([nN]([oO])?))" },
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_nl_langinfo_1(const char *locale, struct langinfo_test *test)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (void) snprintf(tname, sizeof (tname), "nl_langinfo (locale %s)",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "setlocale failed: %s", strerror(errno));
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "setlocale got %s instead of %s", v, locale);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore for (int i = 0; test[i].value != NULL; i++) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore "param %d wrong, expected [%s], got [%s]",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_nl_langinfo_l(const char *locale, struct langinfo_test *test)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (void) snprintf(tname, sizeof (tname), "nl_langinfo_l (locale %s)",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "setlocale failed: %s", strerror(errno));
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "setlocale got %s instead of %s", v, "C");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "newlocale failed: %s", strerror(errno));
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore for (int i = 0; test[i].value != NULL; i++) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore "param %d wrong, expected [%s], got [%s]",
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore for (int i = 0; locales[i].locale != NULL; i++) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_nl_langinfo_1(locales[i].locale, locales[i].loctest);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_nl_langinfo_l(locales[i].locale, locales[i].loctest);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore while ((optc = getopt(argc, argv, "df")) != EOF) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (void) fprintf(stderr, "Usage: %s [-df]\n", argv[0]);