test-scm-take-locale-symbol.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /* Exercise `scm_take_locale_symbol ()', making sure it returns an interned
  18. symbol. See https://savannah.gnu.org/bugs/index.php?25865 . */
  19. #ifdef HAVE_CONFIG_H
  20. # include <config.h>
  21. #endif
  22. #include <libguile.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. static void *
  26. do_test (void *result)
  27. {
  28. SCM taken_sym, sym;
  29. taken_sym = scm_take_locale_symbol (strdup ("some random symbol"));
  30. sym = scm_from_locale_symbol ("some random symbol");
  31. if (scm_is_true (scm_symbol_p (sym))
  32. && scm_is_true (scm_symbol_p (taken_sym))
  33. /* Relying solely on `scm_symbol_interned_p ()' is insufficient since
  34. it doesn't reflect the actual state of the symbol hashtable, hence
  35. the additional `scm_is_eq' test. */
  36. && scm_is_true (scm_symbol_interned_p (sym))
  37. && scm_is_true (scm_symbol_interned_p (taken_sym))
  38. && scm_is_eq (taken_sym, sym))
  39. * (int *) result = EXIT_SUCCESS;
  40. else
  41. * (int *) result = EXIT_FAILURE;
  42. return NULL;
  43. }
  44. int
  45. main (int argc, char *argv[])
  46. {
  47. int result;
  48. scm_with_guile (do_test, &result);
  49. return result;
  50. }