summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test/string.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-09-11 18:49:08 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-09-11 18:49:08 +0900
commit04b098d000c129b1efde98904b9a1b411b32a46a (patch)
treecc48ce54734180b008dc656d8c35580d1454b342 /mrbgems/mruby-string-ext/test/string.rb
parent8c90b5fc6a84c2524c6b7c3bf8920790b00d7431 (diff)
downloadmruby-04b098d000c129b1efde98904b9a1b411b32a46a.tar.gz
mruby-04b098d000c129b1efde98904b9a1b411b32a46a.zip
Move tests related to `getbyte`, `setbyte`, byteslice` to core.
Diffstat (limited to 'mrbgems/mruby-string-ext/test/string.rb')
-rw-r--r--mrbgems/mruby-string-ext/test/string.rb79
1 files changed, 0 insertions, 79 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb
index edbeb02d7..6914fe31d 100644
--- a/mrbgems/mruby-string-ext/test/string.rb
+++ b/mrbgems/mruby-string-ext/test/string.rb
@@ -10,85 +10,6 @@ def assert_upto(exp, receiver, *args)
assert_equal exp, act
end
-assert('String#getbyte') do
- str1 = "hello"
- bytes1 = [104, 101, 108, 108, 111]
- assert_equal bytes1[0], str1.getbyte(0)
- assert_equal bytes1[-1], str1.getbyte(-1)
- assert_equal bytes1[6], str1.getbyte(6)
-
- str2 = "\xFF"
- bytes2 = [0xFF]
- assert_equal bytes2[0], str2.getbyte(0)
-end
-
-assert('String#setbyte') do
- str1 = "hello"
- h = "H".getbyte(0)
- str1.setbyte(0, h)
- assert_equal(h, str1.getbyte(0))
- assert_equal("Hello", str1)
-end
-
-assert('String#byteslice') do
- str1 = "hello"
- str2 = "\u3042ab" # "\xE3\x81\x82ab"
-
- assert_equal("h", str1.byteslice(0))
- assert_equal("e", str1.byteslice(1))
- assert_equal(nil, str1.byteslice(5))
- assert_equal("o", str1.byteslice(-1))
- assert_equal(nil, str1.byteslice(-6))
- assert_equal("\xE3", str2.byteslice(0))
- assert_equal("\x81", str2.byteslice(1))
- assert_equal(nil, str2.byteslice(5))
- assert_equal("b", str2.byteslice(-1))
- assert_equal(nil, str2.byteslice(-6))
-
- assert_equal("", str1.byteslice(0, 0))
- assert_equal(str1, str1.byteslice(0, 6))
- assert_equal("el", str1.byteslice(1, 2))
- assert_equal("", str1.byteslice(5, 1))
- assert_equal("o", str1.byteslice(-1, 6))
- assert_equal(nil, str1.byteslice(-6, 1))
- assert_equal(nil, str1.byteslice(0, -1))
- assert_equal("", str2.byteslice(0, 0))
- assert_equal(str2, str2.byteslice(0, 6))
- assert_equal("\x81\x82", str2.byteslice(1, 2))
- assert_equal("", str2.byteslice(5, 1))
- assert_equal("b", str2.byteslice(-1, 6))
- assert_equal(nil, str2.byteslice(-6, 1))
- assert_equal(nil, str2.byteslice(0, -1))
-
- assert_equal("ell", str1.byteslice(1..3))
- assert_equal("el", str1.byteslice(1...3))
- assert_equal("h", str1.byteslice(0..0))
- assert_equal("", str1.byteslice(5..0))
- assert_equal("o", str1.byteslice(4..5))
- assert_equal(nil, str1.byteslice(6..0))
- assert_equal("", str1.byteslice(-1..0))
- assert_equal("llo", str1.byteslice(-3..5))
- assert_equal("\x81\x82a", str2.byteslice(1..3))
- assert_equal("\x81\x82", str2.byteslice(1...3))
- assert_equal("\xE3", str2.byteslice(0..0))
- assert_equal("", str2.byteslice(5..0))
- assert_equal("b", str2.byteslice(4..5))
- assert_equal(nil, str2.byteslice(6..0))
- assert_equal("", str2.byteslice(-1..0))
- assert_equal("\x82ab", str2.byteslice(-3..5))
-
- assert_raise(ArgumentError) { str1.byteslice }
- assert_raise(ArgumentError) { str1.byteslice(1, 2, 3) }
- assert_raise(TypeError) { str1.byteslice("1") }
- assert_raise(TypeError) { str1.byteslice("1", 2) }
- assert_raise(TypeError) { str1.byteslice(1, "2") }
- assert_raise(TypeError) { str1.byteslice(1..2, 3) }
-
- skip unless Object.const_defined?(:Float)
- assert_equal("o", str1.byteslice(4.0))
- assert_equal("\x82ab", str2.byteslice(2.0, 3.0))
-end
-
assert('String#dump') do
assert_equal("\"\\x00\"", "\0".dump)
assert_equal("\"foo\"", "foo".dump)