Have `scm_take_locale_symbol ()' return an interned symbol (fixes bug #25865).
[bpt/guile.git] / test-suite / standalone / test-scm-take-locale-symbol.c
CommitLineData
05588a1a
LC
1/* Copyright (C) 2009 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This 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 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18/* Exercise `scm_take_locale_symbol ()', making sure it returns an interned
19 symbol. See https://savannah.gnu.org/bugs/index.php?25865 . */
20
21#ifdef HAVE_CONFIG_H
22# include <config.h>
23#endif
24
25#include <libguile.h>
26
27#include <stdlib.h>
28#include <string.h>
29
30\f
31static void *
32do_test (void *result)
33{
34 SCM taken_sym, sym;
35
36 taken_sym = scm_take_locale_symbol (strdup ("some random symbol"));
37 sym = scm_from_locale_symbol ("some random symbol");
38
39 if (scm_is_true (scm_symbol_p (sym))
40 && scm_is_true (scm_symbol_p (taken_sym))
41
42 /* Relying solely on `scm_symbol_interned_p ()' is insufficient since
43 it doesn't reflect the actual state of the symbol hashtable, hence
44 the additional `scm_is_eq' test. */
45 && scm_is_true (scm_symbol_interned_p (sym))
46 && scm_is_true (scm_symbol_interned_p (taken_sym))
47 && scm_is_eq (taken_sym, sym))
48 * (int *) result = EXIT_SUCCESS;
49 else
50 * (int *) result = EXIT_FAILURE;
51
52 return NULL;
53}
54
55int
56main (int argc, char *argv[])
57{
58 int result;
59
60 scm_with_guile (do_test, &result);
61
62 return result;
63}