Sha256: 80a3496592df0216bc2bb8858acff123afe8ec7ac32a6dd17137fb54a0036ea8
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx' require 'stringio' class TestPixelsToRowCol < Minitest::Test def setup @workbook = WriteXLSX.new(StringIO.new) @worksheet = @workbook.add_worksheet('') end def width_to_pixels(width) max_digit_width = 7.0 padding = 5 if width < 1 pixels = (width * (max_digit_width + padding) + 0.5).to_i else pixels = (width * max_digit_width + 0.5).to_i + padding end pixels end def height_to_pixels(height) (4.0 * height / 3).to_i end def test_pixel_to_width (0..1790).each do |pixels| caption = "\tWorksheet: pixcel_to_width(#{pixels})" expected = pixels result = width_to_pixels(@worksheet.__send__(:pixels_to_width, pixels)) assert_equal(expected, result, caption) end end def test_pixel_to_height (0..545).each do |pixels| caption = "\tWorksheet: pixcel_to_height(#{pixels})" expected = pixels result = height_to_pixels(@worksheet.__send__(:pixels_to_height, pixels)) assert_equal(expected, result, caption) end end end
Version data entries
5 entries across 5 versions & 1 rubygems