aboutsummaryrefslogtreecommitdiffstats
path: root/test/csv/test_encodings.rb
diff options
context:
space:
mode:
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 = { })