aboutsummaryrefslogtreecommitdiffstats
path: root/test/csv/test_encodings.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 04:39:16 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 04:39:16 +0000
commit5c1941a9be56a979c27d740370b781882d344f79 (patch)
tree7478e42cde5b470b4df2eb40f89ee25f2621f5aa /test/csv/test_encodings.rb
parentdfc56b8c432d6a374c18cba7048d05175bcfba05 (diff)
downloadruby-5c1941a9be56a979c27d740370b781882d344f79.tar.gz
Merge csv-1.0.2 from upstream.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/test_encodings.rb')
-rwxr-xr-xtest/csv/test_encodings.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb
index 7460a3ff34..fcad90e007 100755
--- a/test/csv/test_encodings.rb
+++ b/test/csv/test_encodings.rb
@@ -4,9 +4,7 @@
# tc_encodings.rb
#
-# Created by James Edward Gray II on 2008-09-13.
-# Copyright 2008 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
+# Created by James Edward Gray II on 2005-10-31.
require_relative "base"
@@ -256,6 +254,22 @@ class TestCSV::Encodings < TestCSV
assert_equal(["foo,\u3042\n".encode(Encoding::Windows_31J), Encoding::Windows_31J], [s, s.encoding], bug9766)
end
+ def test_row_separator_detection_with_invalid_encoding
+ csv = CSV.new("invalid,\xF8\r\nvalid,x\r\n".force_encoding("UTF-8"),
+ encoding: "UTF-8")
+ assert_equal("\r\n", csv.row_sep)
+ end
+
+ def test_invalid_encoding_row_error
+ csv = CSV.new("invalid,\xF8\r\nvalid,x\r\n".force_encoding("UTF-8"),
+ encoding: "UTF-8")
+ error = assert_raise(CSV::MalformedCSVError) do
+ csv.shift
+ end
+ assert_equal("Invalid byte sequence in UTF-8 in line 1.",
+ error.message)
+ end
+
private
def assert_parses(fields, encoding, options = { })