Sha256: eec41dee593446b295ed145fd91836979b85c2f4f3662b222930d82921350b49

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative './support/with_xlsx_file'

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

  def test_auto_width
    with_xlsx_file do |wb|
      ws = wb.add_worksheet

      ws.add_row ['asd', 'asdf', 'asdfg', 'asdfgh', 'asdfghj', 'd'*250]
      assert_in_epsilon(4.4, ws.get_column_auto_width('A'))
      assert_in_epsilon(4.4, ws.get_column_auto_width('B'))
      assert_in_epsilon(5.5, ws.get_column_auto_width('C'))
      assert_in_epsilon(6.6, ws.get_column_auto_width('D'))
      assert_in_epsilon(6.6, ws.get_column_auto_width('E'))
      assert_in_epsilon(255, ws.get_column_auto_width('F'))

      wb.add_format :f, font_size: 14
      ws.add_row ['asd', 'asdf', 'asdfg', 'asdfgh', 'asdfghj'], style: :f
      assert_in_epsilon(5.6, ws.get_column_auto_width('A'))
      assert_in_epsilon(5.6, ws.get_column_auto_width('B'))
      assert_in_epsilon(7.0, ws.get_column_auto_width('C'))
      assert_in_epsilon(8.4, ws.get_column_auto_width('D'))
      assert_in_epsilon(8.4, ws.get_column_auto_width('E'))

      assert_raise(XlsxWriter::Error.new('Function parameter validation error.')) do
        ws.write_rich_string('A2', [])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xlsxwriter-0.2.1.pre.2 test/test-ruby-worksheet.rb
xlsxwriter-0.2.1.pre test/test-ruby-worksheet.rb
xlsxwriter-0.2.0 test/test-ruby-worksheet.rb
xlsxwriter-0.2.0.pre.2 test/test-ruby-worksheet.rb