Sha256: af1cfbacf33700d3889efc6bd93539bc2970e04cd8142fb14545a86853e545f6

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

require 'tc_helper.rb'

class TestSharedStringsTable < Test::Unit::TestCase

  def setup
    @p = Axlsx::Package.new :use_shared_strings=>true
    ws = @p.workbook.add_worksheet
    ws.add_row ['a', 1, 'b']
    ws.add_row ['b', 1, 'c']
    ws.add_row ['c', 1, 'd']
  end

  def test_workbook_has_shared_strings
    assert(@p.workbook.shared_strings.is_a?(Axlsx::SharedStringsTable), "shared string table was not created")
  end

  def test_count
    sst = @p.workbook.shared_strings
    assert_equal(sst.count, 6)
  end

  def test_unique_count
    sst = @p.workbook.shared_strings
    assert_equal(sst.unique_count, 4)
  end

  def test_uses_workbook_xml_space
    assert_equal(@p.workbook.xml_space, @p.workbook.shared_strings.xml_space)
    @p.workbook.xml_space = :default
    assert_equal(:default, @p.workbook.shared_strings.xml_space)
  end

  def test_valid_document
    schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
    doc = Nokogiri::XML(@p.workbook.shared_strings.to_xml_string)
    errors = []
    schema.validate(doc).each do |error|
      puts error.message
      errors << error
    end
    assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map{ |e| e.message }.to_s)
  end

end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
caxlsx-2.0.2 test/workbook/tc_shared_strings_table.rb
axlsx-2.1.0.pre test/workbook/tc_shared_strings_table.rb
l_axlsx-2.0.1 test/workbook/tc_shared_strings_table.rb
axlsx-2.0.1 test/workbook/tc_shared_strings_table.rb
axlsx-2.0.0 test/workbook/tc_shared_strings_table.rb