diff options
| author | Winfield Peterson <[email protected]> | 2018-02-06 17:22:59 -0500 |
|---|---|---|
| committer | Winfield Peterson <[email protected]> | 2018-02-06 17:22:59 -0500 |
| commit | b34286f6975679e9e5eb390241eb05f95759461b (patch) | |
| tree | 0a29cae498abf7f0bb06ea91dbbb09b1da005261 /test/tc_axlsx.rb | |
| parent | ccc69882c6ec4fb8286282313620bceac32e592d (diff) | |
| download | caxlsx-b34286f6975679e9e5eb390241eb05f95759461b.tar.gz caxlsx-b34286f6975679e9e5eb390241eb05f95759461b.zip | |
Adds Axlsx.sanitize() unit tests
Verify frozen/unfrozen paths for sanitize() helper.
Diffstat (limited to 'test/tc_axlsx.rb')
| -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 |
