diff options
| author | Johnny Shields <[email protected]> | 2023-04-13 00:05:25 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-13 00:05:25 +0900 |
| commit | 5f4cf9a12235697b21e666927ed7d08ef18bf15b (patch) | |
| tree | fe696d452e0b8131e4dd2369d6038407eb524f64 /test/tc_axlsx.rb | |
| parent | 467ac5cb9e03ff975929dd5bf473b75f7b6f1b6c (diff) | |
| parent | e548f377932207130cec4ac257a3907385d547d5 (diff) | |
| download | caxlsx-5f4cf9a12235697b21e666927ed7d08ef18bf15b.tar.gz caxlsx-5f4cf9a12235697b21e666927ed7d08ef18bf15b.zip | |
Merge branch 'master' into escape-formulas-improvement
Diffstat (limited to 'test/tc_axlsx.rb')
| -rw-r--r-- | test/tc_axlsx.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 24c233ac..73fdd9ab 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -1,9 +1,9 @@ require 'tc_helper.rb' class TestAxlsx < Test::Unit::TestCase - def setup_wide - @wide_test_points = { "A3" => 0, + @wide_test_points = { + "A3" => 0, "Z3" => 25, "B3" => 1, "AA3" => 1 * 26 + 0, @@ -32,6 +32,7 @@ class TestAxlsx < Test::Unit::TestCase Axlsx.trust_input = old end + def test_cell_range_relative p = Axlsx::Package.new ws = p.workbook.add_worksheet @@ -63,7 +64,7 @@ class TestAxlsx < Test::Unit::TestCase def test_name_to_indices setup_wide @wide_test_points.each do |key, value| - assert_equal(Axlsx.name_to_indices(key), [value,2]) + assert_equal(Axlsx.name_to_indices(key), [value, 2]) end end @@ -105,9 +106,9 @@ class TestAxlsx < Test::Unit::TestCase assert_equal(sanitized_str, legit_str, 'should preserve value') assert_equal(sanitized_str.object_id, legit_str.object_id, 'should preserve object') end - + class InstanceValuesSubject - def initialize(args={}) + def initialize(args = {}) args.each do |key, v| instance_variable_set("@#{key}".to_sym, v) end @@ -119,24 +120,24 @@ class TestAxlsx < Test::Unit::TestCase assert_equal({}, Axlsx.instance_values_for(empty), 'should generate with no ivars') single = InstanceValuesSubject.new(a: 2) - assert_equal({"a" => 2}, Axlsx.instance_values_for(single), 'should generate for a single ivar') + assert_equal({ "a" => 2 }, Axlsx.instance_values_for(single), 'should generate for a single ivar') double = InstanceValuesSubject.new(a: 2, b: "c") - assert_equal({"a" => 2, "b" => "c"}, Axlsx.instance_values_for(double), 'should generate for multiple ivars') + assert_equal({ "a" => 2, "b" => "c" }, Axlsx.instance_values_for(double), 'should generate for multiple ivars') inner_obj = Object.new complex = InstanceValuesSubject.new(obj: inner_obj) - assert_equal({"obj" => inner_obj}, Axlsx.instance_values_for(complex), 'should pass value of ivar directly') + assert_equal({ "obj" => inner_obj }, Axlsx.instance_values_for(complex), 'should pass value of ivar directly') nil_subject = InstanceValuesSubject.new(nil_obj: nil) - assert_equal({"nil_obj" => nil}, Axlsx.instance_values_for(nil_subject), 'should return nil ivars') + assert_equal({ "nil_obj" => nil }, Axlsx.instance_values_for(nil_subject), 'should return nil ivars') end def test_hash_deep_merge - h1 = {foo: {bar: true}} - h2 = {foo: {baz: true}} - assert_equal({foo: {baz: true}}, h1.merge(h2)) - assert_equal({foo: {bar: true, baz: true}}, Axlsx.hash_deep_merge(h1, h2)) + h1 = { foo: { bar: true } } + h2 = { foo: { baz: true } } + assert_equal({ foo: { baz: true } }, h1.merge(h2)) + assert_equal({ foo: { bar: true, baz: true } }, Axlsx.hash_deep_merge(h1, h2)) end def test_escape_formulas |
