# File tests/tokenizertester.rb, line 39
    def test_entity_replacement
	t = NQXML::Tokenizer.new('')

	# add a method that lets us set the internal entity hash
	class << t
	    def testSetInternalEntities(h); @internalEntities = h; end
	end

	t.testSetInternalEntities({ # as if we saw <!ENTITY...> tags
	    'a' => '&b;',
	    'b' => '&foo;',
	    'foo' => '&bar;',
	    'bar' => 'bletch',
	    'ugly' => 'An ampersand (&#38;) may be escaped' +
			' numerically (&#38;#38;) or with a general' +
			' entity (&amp;amp;).'
	})

	assert_equal('x <&> x', t.replaceAllRefsButParams('x &lt;&amp;&gt; x'))
	assert_equal('x "\ x', t.replaceAllRefsButParams('x &quot;&apos; x'))
	assert_equal('x A x', t.replaceAllRefsButParams('x &#65; x'))
	assert_equal('x A x', t.replaceAllRefsButParams('x &#x41; x'))
	assert_equal('&&', t.replaceAllRefsButParams('&amp;&#38;'))

	assert_equal('&amp', t.replaceAllRefsButParams('&amp'))
	assert_equal('&', t.replaceAllRefsButParams('&amp;'))

	assert_equal('bletch', t.replaceAllRefsButParams('&bar;'))
	assert_equal('bletch', t.replaceAllRefsButParams('&foo;'))
	assert_equal('bletch', t.replaceAllRefsButParams('&b;'))
	assert_equal('bletch', t.replaceAllRefsButParams('&a;'))

	assert_equal('An ampersand (&) may be escaped' +
		     ' numerically (&#38;) or with a general' +
		     ' entity (&amp;).', t.replaceAllRefsButParams('&ugly;'))

	# Make sure unknown entities raise an error
	expect_error('x &huh; x', /entity reference '&huh;' is undefined/)
    end