diff options
author | Sutou Kouhei <kou@cozmixng.org> | 2019-10-12 14:03:21 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-12 14:03:21 +0900 |
commit | 92df7d98b62f48cf21cdec522f2e7b34380fd718 (patch) | |
tree | a0d169e177ebd5607caefa26cef90cc70df48232 /test/csv/write | |
parent | d6e68bb263e79cb802fa683d9c4139ddca2fd4f5 (diff) |
Import CSV 3.1.2 (#2547)
Notes
Notes:
Merged-By: kou <kou@clear-code.com>
Diffstat (limited to 'test/csv/write')
-rw-r--r-- | test/csv/write/test_general.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/csv/write/test_general.rb b/test/csv/write/test_general.rb index c879f54e74..d157b74ba1 100644 --- a/test/csv/write/test_general.rb +++ b/test/csv/write/test_general.rb @@ -205,6 +205,32 @@ module TestCSVWriteGeneral assert_equal(%Q[あ,い,う#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"), generate_line(row)) end + + def test_encoding_with_default_internal + with_default_internal(Encoding::UTF_8) do + row = ["あ", "い", "う"].collect {|field| field.encode("EUC-JP")} + assert_equal(%Q[あ,い,う#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"), + generate_line(row, encoding: Encoding::EUC_JP)) + end + end + + def test_with_default_internal + with_default_internal(Encoding::UTF_8) do + row = ["あ", "い", "う"].collect {|field| field.encode("EUC-JP")} + assert_equal(%Q[あ,い,う#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"), + generate_line(row)) + end + end + + def with_default_internal(encoding) + original = Encoding.default_internal + begin + Encoding.default_internal = encoding + yield + ensure + Encoding.default_internal = original + end + end end class TestCSVWriteGeneralGenerateLine < Test::Unit::TestCase |