diff options
| author | Randy Morgan (@morgan_randy) <[email protected]> | 2018-02-07 11:19:54 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-02-07 11:19:54 +0900 |
| commit | 545d77371cf81c368ccfd761e5409cbc7e141711 (patch) | |
| tree | ebf7364735aab38006fe30654e9b5b4f7a954db2 /test | |
| parent | b1d6c0a3ef1bd50228947f48f1034b9d42a9a405 (diff) | |
| parent | b34286f6975679e9e5eb390241eb05f95759461b (diff) | |
| download | caxlsx-545d77371cf81c368ccfd761e5409cbc7e141711.tar.gz caxlsx-545d77371cf81c368ccfd761e5409cbc7e141711.zip | |
Merge pull request #565 from ezcater/safe_frozen_sanitize
Axlsx.sanitize() uses delete() vs. delete!() for frozen strings
Diffstat (limited to 'test')
| -rw-r--r-- | test/tc_axlsx.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 99832f63..3d6a2e70 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -79,4 +79,25 @@ class TestAxlsx < Test::Unit::TestCase 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 |
