Merge commit '5b7632331e7551ac202bbaba37c572b96a791c6e'
[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
53befeb7
NJ
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
05588a1a 7 *
53befeb7
NJ
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
05588a1a
LC
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
53befeb7
NJ
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
05588a1a
LC
17 */
18
19/* Exercise `scm_take_locale_symbol ()', making sure it returns an interned
20 symbol. See https://savannah.gnu.org/bugs/index.php?25865 . */
21
22#ifdef HAVE_CONFIG_H
23# include <config.h>
24#endif
25
26#include <libguile.h>
27
28#include <stdlib.h>
29#include <string.h>
30
31\f
32static void *
33do_test (void *result)
34{
35 SCM taken_sym, sym;
36
37 taken_sym = scm_take_locale_symbol (strdup ("some random symbol"));
38 sym = scm_from_locale_symbol ("some random symbol");
39
40 if (scm_is_true (scm_symbol_p (sym))
41 && scm_is_true (scm_symbol_p (taken_sym))
42
43 /* Relying solely on `scm_symbol_interned_p ()' is insufficient since
44 it doesn't reflect the actual state of the symbol hashtable, hence
45 the additional `scm_is_eq' test. */
46 && scm_is_true (scm_symbol_interned_p (sym))
47 && scm_is_true (scm_symbol_interned_p (taken_sym))
48 && scm_is_eq (taken_sym, sym))
49 * (int *) result = EXIT_SUCCESS;
50 else
51 * (int *) result = EXIT_FAILURE;
52
53 return NULL;
54}
55
56int
57main (int argc, char *argv[])
58{
59 int result;
60
61 scm_with_guile (do_test, &result);
62
63 return result;
64}