summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test/string.rb
blob: 9a75791310a9077c91d8b03f9b62f48752006ac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
##
# String(Ext) Test

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