1
0
Fork 0
This repository has been archived on 2019-12-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neinomaten/vendor/htree/test/test-gencode.rb

27 lines
873 B
Ruby

require 'test/unit'
require 'htree/gencode'
require 'htree/parse'
class TestGenCode < Test::Unit::TestCase
def run_code(code, top_context)
out = HTree::Encoder.new(HTree::Encoder.internal_charset, HTree::Encoder.internal_charset)
eval(code)
out.finish
end
def test_xmlns
t = HTree.parse_xml('<p:n xmlns:p=z><p:m>bb').children[0].children[0] # <p:m>bb</p:m>
code = t.generate_xml_output_code
assert_equal("<p:m xmlns:p=\"z\"\n>bb</p:m\n>", run_code(code, HTree::DefaultContext))
assert_equal("<p:m\n>bb</p:m\n>", run_code(code, HTree::DefaultContext.subst_namespaces("p"=>"z")))
end
def test_xmlns_chref
t = HTree.parse_xml('<p:n xmlns:p="a&amp;<>&quot;b"/>').children[0]
code = t.generate_xml_output_code
assert_equal("<p:n xmlns:p=\"a&amp;&lt;&gt;&quot;b\"\n/>", run_code(code, HTree::DefaultContext))
end
end