Sha256: 1462378f22878784419e3e19bd24ca826c4e5d044a8e4026142873d4f5de0b5a

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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 %w[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

1 entries across 1 versions & 1 rubygems

Version Path
xlsxwriter-0.2.2 test/test_ruby_worksheet.rb