diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 4bd4edfc..7aa0a4ff 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -21,6 +21,15 @@ def test_map assert_equal X, x.class end + def test_hash_roundtrip_with_utf8_key_and_value + string = [1055, 1086, 1079, 1086, 1088, 1080, 1097, 1077].pack("U*") + string.force_encoding 'utf-8' + hash = {string => string} + yml = Psych.dump hash + assert_equal "---\n#{string}: #{string}\n", yml + assert_equal hash, Psych.load(yml) + end + def test_self_referential @hash['self'] = @hash assert_cycle(@hash) diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index c7d5c606..6e1acf19 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -55,6 +55,14 @@ def test_binary_string assert_equal string, Psych.load(yml) end + def test_utf8_string + string = [1055, 1086, 1079, 1086, 1088, 1080, 1097, 1077].pack("U*") + string.force_encoding 'utf-8' + yml = Psych.dump string + assert_equal "--- #{string}\n...\n", yml + assert_equal string, Psych.load(yml) + end + def test_non_binary_string string = binary_string(0.29) yml = Psych.dump string