diff options
| author | Toms Mikoss <[email protected]> | 2020-09-17 10:16:08 +0300 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2020-12-03 23:33:17 +0100 |
| commit | 07f97cb90d59e77d74773851a22a7dd4a8115145 (patch) | |
| tree | d0b28252cc19d500749c5aed7c8d488ae08693ca /test | |
| parent | e4aeec68c8b7bb699db876df375a1e98187b21ac (diff) | |
| download | caxlsx-07f97cb90d59e77d74773851a22a7dd4a8115145.tar.gz caxlsx-07f97cb90d59e77d74773851a22a7dd4a8115145.zip | |
Extend cell_type_from_value with sanity checks
Diffstat (limited to 'test')
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index d6f5aeae..3a7c1566 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -120,6 +120,31 @@ class TestCell < Test::Unit::TestCase assert_equal(:iso_8601, @c.send(:cell_type_from_value, '2008-08-30T01:45:36.123+09:00')) end + def test_cell_type_from_value_looks_like_number_but_is_not + mimic_number = Class.new do + def initialize(to_s_value) + @to_s_value = to_s_value + end + + def to_s + @to_s_value + end + end + + number_strings = [ + '1', + '1234567890', + '1.0', + '1e1', + '0', + "1e#{Float::MIN_10_EXP}" + ] + + number_strings.each do |number_string| + assert_equal(@c.send(:cell_type_from_value, mimic_number.new(number_string)), :string) + end + end + def test_cast_value @c.type = :string assert_equal(@c.send(:cast_value, 1.0), "1.0") |
