Blame gettext-tools/tests/gettext-5-prg.c

Packit 5b56b6
/* Test program, used by the gettext-5 test.
Packit 5b56b6
   Copyright (C) 2005, 2007, 2015 Free Software Foundation, Inc.
Packit 5b56b6
Packit 5b56b6
   This program is free software: you can redistribute it and/or modify
Packit 5b56b6
   it under the terms of the GNU General Public License as published by
Packit 5b56b6
   the Free Software Foundation; either version 3 of the License, or
Packit 5b56b6
   (at your option) any later version.
Packit 5b56b6
Packit 5b56b6
   This program is distributed in the hope that it will be useful,
Packit 5b56b6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5b56b6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 5b56b6
   GNU General Public License for more details.
Packit 5b56b6
Packit 5b56b6
   You should have received a copy of the GNU General Public License
Packit 5b56b6
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 5b56b6
Packit 5b56b6
/* Written by Bruno Haible <haible@clisp.cons.org>, 2005.  */
Packit 5b56b6
Packit 5b56b6
#ifdef HAVE_CONFIG_H
Packit 5b56b6
# include <config.h>
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
#include <locale.h>
Packit 5b56b6
#include <stdlib.h>
Packit 5b56b6
#include <stdio.h>
Packit 5b56b6
#include <string.h>
Packit 5b56b6
Packit 5b56b6
/* Make sure we use the included libintl, not the system's one. */
Packit 5b56b6
#undef _LIBINTL_H
Packit 5b56b6
#include "libgnuintl.h"
Packit 5b56b6
Packit 5b56b6
int
Packit 5b56b6
main (void)
Packit 5b56b6
{
Packit 5b56b6
  char *s;
Packit 5b56b6
  int result = 0;
Packit 5b56b6
Packit 5b56b6
  unsetenv ("LANGUAGE");
Packit 5b56b6
  unsetenv ("OUTPUT_CHARSET");
Packit 5b56b6
  textdomain ("codeset");
Packit 5b56b6
  bindtextdomain ("codeset", "gt-5");
Packit 5b56b6
Packit 5b56b6
  setlocale (LC_ALL, "de_DE.ISO-8859-1");
Packit 5b56b6
Packit 5b56b6
  /* Here we expect output in ISO-8859-1.  */
Packit 5b56b6
  s = gettext ("cheese");
Packit 5b56b6
  if (strcmp (s, "K\344se"))
Packit 5b56b6
    {
Packit 5b56b6
      fprintf (stderr, "call 1 returned: %s\n", s);
Packit 5b56b6
      result = 1;
Packit 5b56b6
    }
Packit 5b56b6
Packit 5b56b6
  setlocale (LC_ALL, "de_DE.UTF-8");
Packit 5b56b6
Packit 5b56b6
  /* Here we expect output in UTF-8.  */
Packit 5b56b6
  s = gettext ("cheese");
Packit 5b56b6
  if (strcmp (s, "K\303\244se"))
Packit 5b56b6
    {
Packit 5b56b6
      fprintf (stderr, "call 2 returned: %s\n", s);
Packit 5b56b6
      result = 1;
Packit 5b56b6
    }
Packit 5b56b6
Packit 5b56b6
  return result;
Packit 5b56b6
}