Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UTF-8 roundtrip tests #46

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/psych/test_hash.rb
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/psych/test_string.rb
Expand Up @@ -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
Expand Down