summaryrefslogtreecommitdiff
path: root/test/psych/test_string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych/test_string.rb')
-rw-r--r--test/psych/test_string.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 4aa6016a59..973f38b9c2 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -1,5 +1,5 @@
# encoding: UTF-8
-# frozen_string_literal: false
+# frozen_string_literal: true
require_relative 'helper'
module Psych
@@ -166,7 +166,7 @@ string: &70121654388580 !ruby/string
end
def test_nonascii_string_as_binary
- string = "hello \x80 world!"
+ string = "hello \x80 world!".dup
string.force_encoding 'ascii-8bit'
yml = Psych.dump string
assert_match(/binary/, yml)
@@ -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)
@@ -202,7 +202,7 @@ string: &70121654388580 !ruby/string
end
def test_string_with_ivars
- food = "is delicious"
+ food = "is delicious".dup
ivar = "on rock and roll"
food.instance_variable_set(:@we_built_this_city, ivar)
@@ -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