Sha256: 4556cfae98ca344ddf1e1a60081d012fc05b7e6c63c104dcd66cd18a6ac2a733

Contents?: true

Size: 899 Bytes

Versions: 5

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

require 'test/unit'
require 'support/with_xlsx_file'

class TestErrors < Test::Unit::TestCase
  include WithXlsxFile

  def test_long_sheet_name
    with_xlsx_file('tmp/error_long_sheet_name.xlsx') do |wb|
      was_in_block = false
      assert_raise(XlsxWriter::Error.new('worksheet was not created')) do
        wb.add_worksheet('a' * 32) do |ws|
          was_in_block = true
          ws.add_row(['test'])
        end
      end
      assert_equal(was_in_block, false)
    end
  end

  def test_written_rich_string
    with_xlsx_file('tmp/error_written_rich_string.xlsx') do |wb|
      ws = wb.add_worksheet
      rs = XlsxWriter::RichString.new(wb, ['1'])
      rs << ' 2'
      ws.add_row([rs])
      assert_raise(XlsxWriter::Error.new('Cannot modify as the RichString has already been written to a workbook.')) do
        rs << ' 3'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xlsxwriter-0.2.2 test/test_errors.rb
xlsxwriter-0.2.1.pre.2 test/test-errors.rb
xlsxwriter-0.2.1.pre test/test-errors.rb
xlsxwriter-0.2.0 test/test-errors.rb
xlsxwriter-0.2.0.pre.2 test/test-errors.rb