summaryrefslogtreecommitdiff
path: root/test/csv/interface/test_read.rb
diff options
context:
space:
mode:
authorKoichi ITO <koic.ito@gmail.com>2020-06-04 12:08:05 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-20 02:32:52 +0900
commitcee10c1b7033f4682b3f4c76220c0c190e70aa1a (patch)
tree17f341739f1f98fd9679b505de594914f6a9ccc6 /test/csv/interface/test_read.rb
parent4e33a878793a5ced47a4f14b8a73cbc2795d97b7 (diff)
[ruby/csv] Fix an error for `CSV.open` (#131)
Follow up to https://github.com/ruby/csv/pull/130/files#r434885191. This PR fixes `ArgumentError` for `CSV.open` when processing invalid byte sequence in UTF-8. https://github.com/ruby/csv/commit/a4b528c209
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3332
Diffstat (limited to 'test/csv/interface/test_read.rb')
-rw-r--r--test/csv/interface/test_read.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/csv/interface/test_read.rb b/test/csv/interface/test_read.rb
index 4b0f5e7e96c..a2bcceda88c 100644
--- a/test/csv/interface/test_read.rb
+++ b/test/csv/interface/test_read.rb
@@ -125,6 +125,16 @@ class TestCSVInterfaceRead < Test::Unit::TestCase
end
end
+ def test_open_invalid_byte_sequence_in_utf_8
+ CSV.open(@input.path, "w", encoding: Encoding::CP932) do |rows|
+ error = assert_raise(Encoding::InvalidByteSequenceError) do
+ rows << ["\x82\xa0"]
+ end
+ assert_equal('"\x82" on UTF-8',
+ error.message)
+ end
+ end
+
def test_open_with_undef_replace
# U+00B7 Middle Dot
CSV.open(@input.path, "w", encoding: Encoding::CP932, undef: :replace) do |rows|