tst-translit.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Test of translitation in the gettext functions.
  2. Copyright (C) 2000-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <libintl.h>
  16. #include <locale.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <unistd.h>
  21. static int
  22. do_test (void)
  23. {
  24. int result = 0;
  25. const char *s;
  26. setenv ("LANGUAGE", "existing-locale", 1);
  27. unsetenv ("OUTPUT_CHARSET");
  28. setlocale (LC_ALL, "en_US.ANSI_X3.4-1968");
  29. textdomain ("translit");
  30. bindtextdomain ("translit", OBJPFX "domaindir");
  31. #define TEST(in, exp) \
  32. s = gettext (in); \
  33. puts (s); \
  34. result |= strcmp (s, exp) != 0;
  35. TEST ("test", "<<(C) AEss>>");
  36. TEST ("test", "<<(C) AEss>>");
  37. TEST ("onemore", " 1/2 * 1/2 = 1/4 ");
  38. TEST ("onemore", " 1/2 * 1/2 = 1/4 ");
  39. TEST ("test", "<<(C) AEss>>");
  40. return result;
  41. }
  42. #define TEST_FUNCTION do_test ()
  43. #include "../test-skeleton.c"