summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorWeston Ganger <[email protected]>2020-02-12 16:07:52 -0800
committerGitHub <[email protected]>2020-02-13 01:07:52 +0100
commit5a5c09132060f1270849c2535d00c456a31fa02a (patch)
tree3a05366e3e9795266f08ce17fa6d0e387eb8747d /test
parenta58375fa72fac090d6310e2094808e8a477eab82 (diff)
downloadcaxlsx-5a5c09132060f1270849c2535d00c456a31fa02a.tar.gz
caxlsx-5a5c09132060f1270849c2535d00c456a31fa02a.zip
Improve cell string_autowidth calculations (#44)
Previously, cells with autowidth sometimes were too narrow for the content to fit. The original width calculation tried to take the difference between narrow and wide chars into account, but it didn’t work out very well. The new calculation is simpler. Compared to the previous implementation it results in cells being slightly wider in most cases.
Diffstat (limited to 'test')
-rw-r--r--test/workbook/worksheet/tc_cell.rb2
-rw-r--r--test/workbook/worksheet/tc_rich_text_run.rb5
2 files changed, 4 insertions, 3 deletions
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index d3ca9fe8..9e0bdc0e 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -61,7 +61,7 @@ class TestCell < Test::Unit::TestCase
def test_autowidth
style = @c.row.worksheet.workbook.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}} )
@c.style = style
- assert_equal(@c.autowidth, 5.5)
+ assert_in_delta(6.6, @c.autowidth, 0.01)
end
def test_time
diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb
index e4a5ef80..39919a31 100644
--- a/test/workbook/worksheet/tc_rich_text_run.rb
+++ b/test/workbook/worksheet/tc_rich_text_run.rb
@@ -148,8 +148,9 @@ class RichTextRun < Test::Unit::TestCase
@ws.add_row [rt], :style => wrap
ar = [0]
awtr.autowidth(ar)
- assert_equal(ar.length, 2)
- assert_equal(ar.last, 0)
+ assert_equal(2, ar.length)
+ assert_equal(13.2, ar[0])
+ assert_equal(0, ar[1])
end
def test_to_xml