# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/package/xml_writer_simple' class TestXMLWriterSimple < Test::Unit::TestCase def setup @obj = Writexlsx::Package::XMLWriterSimple.new end def test_xml_decl assert_equal( %Q!\n!, @obj.xml_decl ) end def test_empty_tag assert_equal('', @obj.empty_tag('foo')) end def test_empty_tag_with_xml_decl expected = < EOS assert_equal(expected, @obj.xml_decl << @obj.empty_tag('foo') << "\n") end def test_start_end_tag assert_equal("", @obj.start_tag('foo') << @obj.end_tag('foo')) end def test_attribute assert_equal( "", @obj.empty_tag("foo", ['x', '1>2']) ) end def test_character_data assert_equal( "<tag>&amp;</tag>", @obj.start_tag('foo') << @obj.characters("&") << @obj.end_tag('foo') ) end def test_data_element_with_empty_attr assert_equal( "data", @obj.data_element('foo', 'data') ) end def test_data_element attributes = [ 'name', '_xlnm.Print_Titles', 'localSheetId', 0 ] assert_equal( "Sheet1!$1:$1", @obj.data_element('definedName', 'Sheet1!$1:$1', attributes) ) end end