Sha256: fc6c28f0c4a2c0fa2ff7a9ec82c76132f5a76179c8f794517bac112f34e002d8

Contents?: true

Size: 1001 Bytes

Versions: 19

Compression:

Stored size: 1001 Bytes

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_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

19 entries across 19 versions & 1 rubygems

Version Path
axlsx-1.3.6 test/workbook/tc_shared_strings_table.rb
axlsx-1.3.5 test/workbook/tc_shared_strings_table.rb
axlsx-1.3.4 test/workbook/tc_shared_strings_table.rb
axlsx-1.3.3 test/workbook/tc_shared_strings_table.rb
axlsx-1.3.2 test/workbook/tc_shared_strings_table.rb
axlsx-1.3.1 test/workbook/tc_shared_strings_table.rb
axlsx-1.2.3 test/workbook/tc_shared_strings_table.rb
axlsx-1.2.2 test/workbook/tc_shared_strings_table.rb
axlsx-1.2.1 test/workbook/tc_shared_strings_table.rb
axlsx-1.2.0 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.8 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.7 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.6 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.5 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.4 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.3 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.2 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.1 test/workbook/tc_shared_strings_table.rb
axlsx-1.1.0 test/workbook/tc_shared_strings_table.rb