Sha256: af06b65d2a5cffd9585cd2e6424b0bd7d2098418cf3f187b873fce0c041abdbe

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'builder/xchar'

class TestXmlEscaping < Test::Unit::TestCase
  def test_ascii
    assert_equal 'abc', 'abc'.to_xs
  end

  def test_predefined
    assert_equal '&amp;', '&'.to_xs              # ampersand
    assert_equal '&lt;',  '<'.to_xs              # left angle bracket
    assert_equal '&gt;',  '>'.to_xs              # right angle bracket
  end

  def test_invalid
    assert_equal '*', "\x00".to_xs               # null
    assert_equal '*', "\x0C".to_xs               # form feed
    assert_equal '*', "\xEF\xBF\xBF".to_xs       # U+FFFF
  end

  def test_iso_8859_1
    assert_equal '&#231;', "\xE7".to_xs          # small c cedilla
    assert_equal '&#169;', "\xA9".to_xs          # copyright symbol
  end

  def test_win_1252
    assert_equal '&#8217;', "\x92".to_xs         # smart quote
    assert_equal '&#8364;', "\x80".to_xs         # euro
  end

  def test_utf8
    assert_equal '&#8217;', "\xE2\x80\x99".to_xs # right single quote
    assert_equal '&#169;',  "\xC2\xA9".to_xs     # copy
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/builder-2.1.2/test/test_xchar.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/builder-2.1.2/test/test_xchar.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/builder-2.1.2/test/test_xchar.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/builder-2.1.2/test/test_xchar.rb
middleman-0.10.17 vendor/gems/gems/builder-2.1.2/test/test_xchar.rb
middleman-0.10.16 vendor/gems/gems/builder-2.1.2/test/test_xchar.rb
middleman-0.10.15 vendor/gems/gems/builder-2.1.2/test/test_xchar.rb
rackjour-0.1.8 vendor/gems/gems/builder-2.1.2/test/test_xchar.rb
middleman-0.10.14 vendor/gems/gems/builder-2.1.2/test/test_xchar.rb
builder-2.0.0 test/test_xchar.rb
builder-2.1.2 test/test_xchar.rb
builder-2.1.1 test/test_xchar.rb