neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

30 lines
1.0 KiB
Ruby

require 'test/unit'
require 'htree/context'
class TestContext < Test::Unit::TestCase
def test_namespaces_validation
assert_raise(ArgumentError) { HTree::Context.new({1=>'u'}) }
assert_raise(ArgumentError) { HTree::Context.new({''=>'u'}) }
assert_raise(ArgumentError) { HTree::Context.new({'p'=>nil}) }
assert_nothing_raised { HTree::Context.new({nil=>'u'}) }
end
def test_namespace_uri
assert_equal('http://www.w3.org/XML/1998/namespace',
HTree::Context.new.namespace_uri('xml'))
assert_equal('u', HTree::Context.new({nil=>'u'}).namespace_uri(nil))
assert_equal('u', HTree::Context.new({'p'=>'u'}).namespace_uri('p'))
assert_equal(nil, HTree::Context.new({'p'=>'u'}).namespace_uri('q'))
end
def test_subst_namespaces
c1 = HTree::Context.new({'p'=>'u'})
c2 = c1.subst_namespaces({'q'=>'v'})
assert_equal('u', c1.namespace_uri('p'))
assert_equal(nil, c1.namespace_uri('q'))
assert_equal('u', c2.namespace_uri('p'))
assert_equal('v', c2.namespace_uri('q'))
end
end