-
-
Notifications
You must be signed in to change notification settings - Fork 897
/
test_encoding_handler.rb
46 lines (36 loc) · 1.18 KB
/
test_encoding_handler.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
require "helper"
class TestEncodingHandler < Nokogiri::TestCase
def teardown
Nokogiri::EncodingHandler.clear_aliases!
end
def test_get
assert_not_nil Nokogiri::EncodingHandler['UTF-8']
assert_nil Nokogiri::EncodingHandler['alsdkjfhaldskjfh']
end
def test_name
eh = Nokogiri::EncodingHandler['UTF-8']
assert_equal "UTF-8", eh.name
end
def test_alias
Nokogiri::EncodingHandler.alias('UTF-8', 'UTF-18')
assert_equal 'UTF-8', Nokogiri::EncodingHandler['UTF-18'].name
end
def test_cleanup_aliases
assert_nil Nokogiri::EncodingHandler['UTF-9']
Nokogiri::EncodingHandler.alias('UTF-8', 'UTF-9')
assert_not_nil Nokogiri::EncodingHandler['UTF-9']
Nokogiri::EncodingHandler.clear_aliases!
assert_nil Nokogiri::EncodingHandler['UTF-9']
end
def test_delete
assert_nil Nokogiri::EncodingHandler['UTF-9']
Nokogiri::EncodingHandler.alias('UTF-8', 'UTF-9')
assert_not_nil Nokogiri::EncodingHandler['UTF-9']
Nokogiri::EncodingHandler.delete 'UTF-9'
assert_nil Nokogiri::EncodingHandler['UTF-9']
end
def test_delete_non_existent
assert_nil Nokogiri::EncodingHandler.delete('UTF-9')
end
end