From: <jh...@us...> - 2011-07-09 00:19:42
|
Revision: 296 http://etch.svn.sourceforge.net/etch/?rev=296&view=rev Author: jheiss Date: 2011-07-09 00:19:36 +0000 (Sat, 09 Jul 2011) Log Message: ----------- Modify test_xmlcopyelem to test that the contents of the element are copied. Modified Paths: -------------- trunk/test/unit/test_xml_abstraction.rb Modified: trunk/test/unit/test_xml_abstraction.rb =================================================================== --- trunk/test/unit/test_xml_abstraction.rb 2011-07-08 23:30:43 UTC (rev 295) +++ trunk/test/unit/test_xml_abstraction.rb 2011-07-09 00:19:36 UTC (rev 296) @@ -341,37 +341,53 @@ end def test_xmlcopyelem file = Tempfile.new('etch_xml_abstraction') - file.puts '<root><element><child/></element><other/></root>' + file.puts '<root><element><child>child text</child></element><other/></root>' file.close doc = Etch.xmlload(file.path) original = Etch.xmlfindfirst(doc, '/root/element/child') Etch.xmlcopyelem(original, Etch.xmlfindfirst(doc, '/root/other')) copy = Etch.xmlfindfirst(doc, '/root/other/child') - # Change the child so that we can test that it is separate from the orignal - Etch.xmlsettext(copy, 'some text') + case Etch.xmllib when :libxml assert_kind_of(LibXML::XML::Node, original) assert_kind_of(LibXML::XML::Node, copy) assert_equal('child', original.name) - assert_equal('', Etch.xmltext(original)) + assert_equal('child text', Etch.xmltext(original)) assert_equal('child', copy.name) - assert_equal('some text', Etch.xmltext(copy)) + assert_equal('child text', Etch.xmltext(copy)) when :nokogiri assert_kind_of(Nokogiri::XML::Element, original) assert_kind_of(Nokogiri::XML::Element, copy) assert_equal('child', original.name) - assert_equal('', Etch.xmltext(original)) + assert_equal('child text', Etch.xmltext(original)) assert_equal('child', copy.name) - assert_equal('some text', Etch.xmltext(copy)) + assert_equal('child text', Etch.xmltext(copy)) when :rexml assert_kind_of(REXML::Element, original) assert_kind_of(REXML::Element, copy) assert_equal('child', original.name) - assert_equal('', Etch.xmltext(original)) + assert_equal('child text', Etch.xmltext(original)) assert_equal('child', copy.name) + assert_equal('child text', Etch.xmltext(copy)) + else + raise "Unknown XML library #{Etch.xmllib}" + end + + # Change the child so that we can test that it is separate from the orignal + Etch.xmlsettext(copy, 'some text') + + case Etch.xmllib + when :libxml + assert_equal('child text', Etch.xmltext(original)) assert_equal('some text', Etch.xmltext(copy)) + when :nokogiri + assert_equal('child text', Etch.xmltext(original)) + assert_equal('some text', Etch.xmltext(copy)) + when :rexml + assert_equal('child text', Etch.xmltext(original)) + assert_equal('some text', Etch.xmltext(copy)) else raise "Unknown XML library #{Etch.xmllib}" end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |