elf: Fix DTV gap reuse logic [BZ #27135]
[glibc.git] / intl / tst-codeset.c
blob94d22310a42cd034db82b16776dd08792d619aa1
1 /* Test of bind_textdomain_codeset.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Bruno Haible <haible@clisp.cons.org>, 2001.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
20 #include <libintl.h>
21 #include <locale.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <support/check.h>
27 static int
28 do_test (void)
30 unsetenv ("LANGUAGE");
31 unsetenv ("OUTPUT_CHARSET");
32 setlocale (LC_ALL, "de_DE.ISO-8859-1");
33 textdomain ("codeset");
34 bindtextdomain ("codeset", OBJPFX "domaindir");
36 /* Here we expect output in ISO-8859-1. */
37 TEST_COMPARE_STRING (gettext ("cheese"), "K\344se");
39 /* Here we expect output in UTF-8. */
40 bind_textdomain_codeset ("codeset", "UTF-8");
41 TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se");
43 /* `a with umlaut' is transliterated to `ae'. */
44 bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT");
45 TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
47 /* Transliteration also works by default even if not set. */
48 bind_textdomain_codeset ("codeset", "ASCII");
49 TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
51 return 0;
54 #include <support/test-driver.c>