summaryrefslogtreecommitdiff
path: root/test/psych/test_string.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-06-29 15:03:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2017-06-29 15:03:15 -0700
commit8949a47b8cee31e03e21608406ba116adcf74054 (patch)
treef82f2abc044b5e59bc4a8d01177c615b6f9eb42b /test/psych/test_string.rb
parent0ecb87ce7169f945c9fce55ef3f1b9d859283a73 (diff)
downloadpsych-8949a47b8cee31e03e21608406ba116adcf74054.tar.gz
Rely on encoding tags to determine if string should be dumped as binary
If a string is tagged as binary, then we should dump it as binary. Fixes #278
Diffstat (limited to 'test/psych/test_string.rb')
-rw-r--r--test/psych/test_string.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 4aa6016..4739147 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -174,7 +174,7 @@ string: &70121654388580 !ruby/string
end
def test_binary_string_null
- string = "\x00"
+ string = "\x00\x92".b
yml = Psych.dump string
assert_match(/binary/, yml)
assert_equal string, Psych.load(yml)
@@ -187,8 +187,8 @@ string: &70121654388580 !ruby/string
assert_equal string, Psych.load(yml)
end
- def test_non_binary_string
- string = binary_string(0.29)
+ def test_ascii_only_binary_string
+ string = "non bnry string".b
yml = Psych.dump string
refute_match(/binary/, yml)
assert_equal string, Psych.load(yml)
@@ -220,9 +220,9 @@ string: &70121654388580 !ruby/string
end
def binary_string percentage = 0.31, length = 100
- string = ''
+ string = ''.b
(percentage * length).to_i.times do |i|
- string << "\b"
+ string << "\x92".b
end
string << 'a' * (length - string.length)
string