sxml.simple.test 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ;;;; sxml.simple.test --- (sxml simple) -*- mode: scheme; coding: utf-8; -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2010 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 3 of the License, or (at your option) any later version.
  9. ;;;;
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. ;;;; Lesser General Public License for more details.
  14. ;;;;
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library; if not, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. (define-module (test-sxml-simple)
  19. #:use-module (test-suite lib)
  20. #:use-module (sxml simple))
  21. (define %xml-sample
  22. ;; An XML sample without any space in between tags, to make it easier.
  23. (string-append "<?xml version='1.0' encoding='utf-8'?>"
  24. "<foo chbouib=\"yes\">"
  25. "<bar/>"
  26. "<baz>"
  27. "<smurf one=\"1\"/>"
  28. "</baz>"
  29. "</foo>"))
  30. (with-test-prefix "simple"
  31. (pass-if "xml->sxml"
  32. (equal? (xml->sxml (open-input-string %xml-sample))
  33. '(*TOP*
  34. (*PI* xml "version='1.0' encoding='utf-8'")
  35. (foo (@ (chbouib "yes"))
  36. (bar)
  37. (baz (smurf (@ (one "1"))))))))
  38. (pass-if "xml->sxml->xml->sxml"
  39. ;; Regression test for bug #29260.
  40. (equal? (xml->sxml (open-input-string %xml-sample))
  41. (xml->sxml
  42. (open-input-string
  43. (with-output-to-string
  44. (lambda ()
  45. (sxml->xml
  46. (xml->sxml (open-input-string %xml-sample))))))))))