From 9ebe3a1cb11484f1bfcc918925dec3704d262a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Holzfu=C3=9F?= Date: Sat, 7 Sep 2024 15:52:07 +0200 Subject: [PATCH] tests: Test that all returned Strings are unfrozen --- spec/lib/ascii85_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/lib/ascii85_spec.rb b/spec/lib/ascii85_spec.rb index 6bab073..415fbac 100644 --- a/spec/lib/ascii85_spec.rb +++ b/spec/lib/ascii85_spec.rb @@ -63,6 +63,12 @@ end end + it 'should always return unfrozen Strings' do + TEST_CASES.each_pair do |input, encoded| + assert_equal false, Ascii85.encode(input).frozen? + end + end + it 'should encode Strings in different encodings correctly' do input_euc_jp = 'どうもありがとうミスターロボット'.encode('EUC-JP') input_binary = input_euc_jp.force_encoding('ASCII-8BIT') @@ -143,6 +149,12 @@ end end + it 'should always return unfrozen Strings' do + TEST_CASES.each_pair do |input, encoded| + assert_equal false, Ascii85.decode(encoded).frozen? + end + end + it 'should accept valid input in encodings other than the default' do input = 'Ragnarök τέχνη русский язык I ♥ Ruby' input_ascii85 = Ascii85.encode(input) @@ -221,6 +233,13 @@ end end + it 'should always return unfrozen Strings' do + TEST_CASES.each_pair do |decoded, input| + raw_input = input[2...-2] # Remove '<~' and '~>' + assert_equal false, Ascii85.decode_raw(raw_input).frozen? + end + end + it 'should decode from an IO object' do input = StringIO.new(';KZGo') result = Ascii85.decode_raw(input)