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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2009,2018
  2. Free Software Foundation, Inc.
  3. This file is part of Guile.
  4. Guile is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Guile is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with Guile. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. /* Exercise `scm_take_locale_symbol ()', making sure it returns an interned
  16. symbol. See https://savannah.gnu.org/bugs/index.php?25865 . */
  17. #ifdef HAVE_CONFIG_H
  18. # include <config.h>
  19. #endif
  20. #include <libguile.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. static void *
  24. do_test (void *result)
  25. {
  26. SCM taken_sym, sym;
  27. taken_sym = scm_take_locale_symbol (strdup ("some random symbol"));
  28. sym = scm_from_locale_symbol ("some random symbol");
  29. if (scm_is_true (scm_symbol_p (sym))
  30. && scm_is_true (scm_symbol_p (taken_sym))
  31. /* Relying solely on `scm_symbol_interned_p ()' is insufficient since
  32. it doesn't reflect the actual state of the symbol hashtable, hence
  33. the additional `scm_is_eq' test. */
  34. && scm_is_true (scm_symbol_interned_p (sym))
  35. && scm_is_true (scm_symbol_interned_p (taken_sym))
  36. && scm_is_eq (taken_sym, sym))
  37. * (int *) result = EXIT_SUCCESS;
  38. else
  39. * (int *) result = EXIT_FAILURE;
  40. return NULL;
  41. }
  42. int
  43. main (int argc, char *argv[])
  44. {
  45. int result;
  46. scm_with_guile (do_test, &result);
  47. return result;
  48. }