File: legacy_test.rb

package info (click to toggle)
libhtmlentities-ruby 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 136 kB
  • ctags: 294
  • sloc: ruby: 2,172; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'htmlentities'
require 'test/unit'

$KCODE = 'u'

#
# Test that version 3.x functionality still works
#
class HTMLEntities::LegacyTest < Test::Unit::TestCase
  
  def test_should_decode_via_legacy_interface
    assert_decode('&', '&amp;')
    assert_decode('±', '&plusmn;')
    assert_decode('“', '&#8220;')
    assert_decode('—', '&#x2014;')
  end

  def test_should_encode_via_legacy_interface
    assert_encode('&amp;', '&', :basic)
    assert_encode('&eth;', 'ð', :named)
    assert_encode('&#8230;', '…', :decimal)
    assert_encode('&#x2212;', '−', :hexadecimal)
  end
  
  def assert_encode(expected, *encode_args)
    assert_equal expected, HTMLEntities.encode_entities(*encode_args)
  end

  def assert_decode(expected, *decode_args)
    assert_equal expected, HTMLEntities.decode_entities(*decode_args)
  end
  
end