PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/drillbit/Resources/tests/ruby/builder/test/test_xchar.rb

http://github.com/appcelerator/titanium_desktop
Ruby | 37 lines | 29 code | 7 blank | 1 comment | 0 complexity | 8c9a776d2bd49c07988b81d16251edf6 MD5 | raw file
Possible License(s): Apache-2.0
  1. #!/usr/bin/env ruby
  2. require 'test/unit'
  3. require 'builder/xchar'
  4. class TestXmlEscaping < Test::Unit::TestCase
  5. def test_ascii
  6. assert_equal 'abc', 'abc'.to_xs
  7. end
  8. def test_predefined
  9. assert_equal '&amp;', '&'.to_xs # ampersand
  10. assert_equal '&lt;', '<'.to_xs # left angle bracket
  11. assert_equal '&gt;', '>'.to_xs # right angle bracket
  12. end
  13. def test_invalid
  14. assert_equal '*', "\x00".to_xs # null
  15. assert_equal '*', "\x0C".to_xs # form feed
  16. assert_equal '*', "\xEF\xBF\xBF".to_xs # U+FFFF
  17. end
  18. def test_iso_8859_1
  19. assert_equal '&#231;', "\xE7".to_xs # small c cedilla
  20. assert_equal '&#169;', "\xA9".to_xs # copyright symbol
  21. end
  22. def test_win_1252
  23. assert_equal '&#8217;', "\x92".to_xs # smart quote
  24. assert_equal '&#8364;', "\x80".to_xs # euro
  25. end
  26. def test_utf8
  27. assert_equal '&#8217;', "\xE2\x80\x99".to_xs # right single quote
  28. assert_equal '&#169;', "\xC2\xA9".to_xs # copy
  29. end
  30. end