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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 License
  5. * as published by the Free Software Foundation; either version 3 of
  6. * the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but
  9. * 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
  16. * 02110-1301 USA
  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. #ifdef HAVE_CONFIG_H
  21. # include <config.h>
  22. #endif
  23. #include <libguile.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. static void *
  27. do_test (void *result)
  28. {
  29. SCM taken_sym, sym;
  30. taken_sym = scm_take_locale_symbol (strdup ("some random symbol"));
  31. sym = scm_from_locale_symbol ("some random symbol");
  32. if (scm_is_true (scm_symbol_p (sym))
  33. && scm_is_true (scm_symbol_p (taken_sym))
  34. /* Relying solely on `scm_symbol_interned_p ()' is insufficient since
  35. it doesn't reflect the actual state of the symbol hashtable, hence
  36. the additional `scm_is_eq' test. */
  37. && scm_is_true (scm_symbol_interned_p (sym))
  38. && scm_is_true (scm_symbol_interned_p (taken_sym))
  39. && scm_is_eq (taken_sym, sym))
  40. * (int *) result = EXIT_SUCCESS;
  41. else
  42. * (int *) result = EXIT_FAILURE;
  43. return NULL;
  44. }
  45. int
  46. main (int argc, char *argv[])
  47. {
  48. int result;
  49. scm_with_guile (do_test, &result);
  50. return result;
  51. }