Skip to content

Commit

Permalink
tests: Test that all returned Strings are unfrozen
Browse files Browse the repository at this point in the history
  • Loading branch information
DataWraith committed Sep 7, 2024
1 parent 1827e1e commit 9ebe3a1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spec/lib/ascii85_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9ebe3a1

Please sign in to comment.