class HTMLUtilsTest

Public Instance Methods

test_escape_comment() click to toggle source
# File ../../../../../test/test_htmlutils.rb, line 29
def test_escape_comment
  assert_equal '<', escape_comment('<')
  assert_equal '>', escape_comment('>')
  assert_equal '&', escape_comment('&')
  assert_equal '&#45;', escape_comment('-')
  assert_equal '&#45;&#45;', escape_comment('--')
end
test_escape_html() click to toggle source
# File ../../../../../test/test_htmlutils.rb, line 7
def test_escape_html
  assert_equal '&lt;', escape_html('<')
  assert_equal '&lt;&lt;', escape_html('<<')
  assert_equal '_&lt;_&lt;_', escape_html('_<_<_')
end
test_escape_html_ex() click to toggle source
# File ../../../../../test/test_htmlutils.rb, line 13
def test_escape_html_ex
  keys = ESC.keys
  ESC['.'] = 'X'
  ESC.each_pair do |ch, ref|
    if keys.include?(ch)
      assert_equal ref, escape_html(ch)
    else
      assert_equal ch, escape_html(ch)
    end
  end
end
test_normalize_id() click to toggle source
# File ../../../../../test/test_htmlutils.rb, line 37
def test_normalize_id
  assert_equal 'abcxyz', normalize_id('abcxyz')
  assert_equal 'ABCXYZ', normalize_id('ABCXYZ')
  assert_equal 'abc0123', normalize_id('abc0123')
  assert_equal 'a-b-c_x.y.z', normalize_id('a-b-c_x.y.z')
  assert_equal 'id_a_3Ab_3Ac', normalize_id('a:b:c')
  assert_equal 'id_0123a-b-c_x.y.z', normalize_id('0123a-b-c_x.y.z')
  assert_equal 'id_.', normalize_id('.')
  assert_equal 'id__E3_81_82', normalize_id('あ')
  assert_equal 'id_-___3B', normalize_id(' _;')
end
test_strip_html() click to toggle source
# File ../../../../../test/test_htmlutils.rb, line 25
def test_strip_html
  assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
end