test/tc_axlsx.rb in axlsx-2.1.0.pre vs test/tc_axlsx.rb in axlsx-3.0.0.pre

- old
+ new

@@ -43,10 +43,20 @@ c1 = row.add_cell c2 = row.add_cell assert_equal(Axlsx.cell_range([c2, c1], true), "'Sheet <''>" 1'!$A$1:$B$1") end + def test_cell_range_row + p = Axlsx::Package.new + ws = p.workbook.add_worksheet + row = ws.add_row + row.add_cell + row.add_cell + row.add_cell + assert_equal("A1:C1", Axlsx.cell_range(row, false)) + end + def test_name_to_indices setup_wide @wide_test_points.each do |key, value| assert_equal(Axlsx.name_to_indices(key), [value,2]) end @@ -67,6 +77,27 @@ assert_equal([['A1', 'B1', 'C1']], Axlsx::range_to_a('A1:C1')) assert_equal([['A1', 'B1', 'C1'], ['A2', 'B2', 'C2']], Axlsx::range_to_a('A1:C2')) assert_equal([['Z5', 'AA5', 'AB5'], ['Z6', 'AA6', 'AB6']], Axlsx::range_to_a('Z5:AB6')) end + def test_sanitize_frozen_control_strippped + needs_sanitize = "legit\x08".freeze # Backspace control char + + assert_equal(Axlsx.sanitize(needs_sanitize), 'legit', 'should strip control chars') + end + + def test_sanitize_unfrozen_control_strippped + needs_sanitize = "legit\x08" # Backspace control char + sanitized_str = Axlsx.sanitize(needs_sanitize) + + assert_equal(sanitized_str, 'legit', 'should strip control chars') + assert_equal(sanitized_str.object_id, sanitized_str.object_id, 'should preserve object') + end + + def test_sanitize_unfrozen_no_sanitize + legit_str = 'legit' + sanitized_str = Axlsx.sanitize(legit_str) + + assert_equal(sanitized_str, legit_str, 'should preserve value') + assert_equal(sanitized_str.object_id, legit_str.object_id, 'should preserve object') + end end