require 'tc_helper.rb' class TestStrData < Test::Unit::TestCase def setup @str_data = Axlsx::StrData.new :data => ["1", "2", "3"] end def test_tag_name assert_raise(ArgumentError) { @str_data.tag_name = :bob} assert_nothing_raised { @str_data.tag_name = :strCache} end def test_initialize assert_equal(@str_data.pt.size, 3) assert(@str_data.pt.is_a? Axlsx::SimpleTypedList) assert_equal(@str_data.tag_name, :strLit) end def test_to_xml_string_strLit @str_data.tag_name = :strLit str = '' str << '' str << @str_data.to_xml_string(0) doc = Nokogiri::XML(str) assert_equal(doc.xpath("//c:strLit/c:ptCount[@val=3]").size, 1) assert_equal(doc.xpath("//c:strLit/c:pt/c:v[text()='1']").size, 1) end end