Merge pull request #522 from bovi/add-test-string-bytes

Add Test for String#bytes
This commit is contained in:
Yukihiro "Matz" Matsumoto
2012-11-01 05:47:16 -07:00
+17
View File
@@ -339,3 +339,20 @@ assert('Check the usage of a NUL character') do
"qqq\0ppp"
end
assert('String#bytes') do
str1 = "hello"
bytes1 = [104, 101, 108, 108, 111]
str1.bytes == bytes1
end
assert('String#each_byte') do
str1 = "hello"
bytes1 = [104, 101, 108, 108, 111]
bytes2 = []
str1.each_byte {|b| bytes2 << b }
bytes1 == bytes2
end