diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 19:42:34 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 19:42:34 +0900 |
commit | 61e594d1508716d9351f3dd355edef6e86e980d9 (patch) | |
tree | 2ee314d6b66cbb862abb3e376aa438dc316acb7e /test | |
parent | 1bb4b371509127fdfe3c59a906e2156b51054ae1 (diff) | |
download | plum-61e594d1508716d9351f3dd355edef6e86e980d9.tar.gz |
binary_string: add String#each_byteslice
Diffstat (limited to 'test')
-rw-r--r-- | test/plum/test_binary_string.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/plum/test_binary_string.rb b/test/plum/test_binary_string.rb index 69c9c3a..403248b 100644 --- a/test/plum/test_binary_string.rb +++ b/test/plum/test_binary_string.rb @@ -48,4 +48,17 @@ class BinaryStringTest < Minitest::Test assert_equal("\xf0".b, sushi.byteshift(1).b) assert_equal("\x9f\x8d\xa3".b, sushi.b) end + + def test_each_byteslice_block + ret = [] + string = "12345678" + string.each_byteslice(3) {|part| ret << part } + assert_equal(["123", "456", "78"], ret) + end + + def test_each_byteslice_enume + string = "12345678" + ret = string.each_byteslice(3) + assert_equal(["123", "456", "78"], ret.to_a) + end end |