Merge branch 'test-ip_mreq_source-android-only' into 'master'
[glib.git] / glib / tests / charset.c
blob0a1c8ce3f42859e182065ec94408e054b0c96562
1 /*
2 * Copyright 2018 Red Hat, Inc.
4 * This program 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.
9 * See the included COPYING file for more information.
12 #include "glib.h"
14 #define TEST_LOCALE "fr_FR.UTF-8@latin:en_US.UTF-8"
16 const gchar *TEST_RESULT[] = {
17 "fr_FR.UTF-8@latin",
18 "fr_FR@latin",
19 "fr.UTF-8@latin",
20 "fr@latin",
21 "fr_FR.UTF-8",
22 "fr_FR",
23 "fr.UTF-8",
24 "fr",
25 "en_US.UTF-8",
26 "en_US",
27 "en.UTF-8",
28 "en",
29 "C",
30 NULL
33 const gchar *TEST_TABLE[] = {
34 "LANGUAGE",
35 "LC_ALL",
36 "LC_CTYPE",
37 "LANG",
38 NULL
41 static void
42 test_language_names_with_category (void)
44 const gchar * const *language_names = NULL;
45 gsize i, j;
47 for (i = 0; TEST_TABLE[i]; ++i)
49 g_test_message ("Test %" G_GSIZE_FORMAT, i);
50 g_assert_true (g_setenv (TEST_TABLE[i], TEST_LOCALE, TRUE));
51 language_names = g_get_language_names_with_category ("LC_CTYPE");
52 g_assert_cmpuint (g_strv_length ((gchar **)language_names), ==, g_strv_length ((gchar **)TEST_RESULT));
54 for (j = 0; language_names[j]; ++j)
56 g_assert_cmpstr (language_names[j], ==, TEST_RESULT[j]);
58 g_unsetenv (TEST_TABLE[i]);
62 int
63 main (int argc, char *argv[])
65 g_test_init (&argc, &argv, NULL);
67 g_test_bug_base ("http://bugs.gnome.org/");
69 g_test_add_func ("/charset/language_names_with_category", test_language_names_with_category);
71 return g_test_run ();