File: unicode.rb

package info (click to toggle)
mruby 1.0.0%2B20141015%2Bgitb4cc962c-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,408 kB
  • ctags: 3,526
  • sloc: ansic: 25,319; ruby: 10,638; yacc: 5,738; sh: 14; makefile: 12
file content (35 lines) | stat: -rw-r--r-- 1,030 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Test of the \u notation

assert('bare \u notation test') do
  # Mininum and maximum one byte characters
  assert_equal("\u0000", "\x00")
  assert_equal("\u007F", "\x7F")

  # Mininum and maximum two byte characters
  assert_equal("\u0080", "\xC2\x80")
  assert_equal("\u07FF", "\xDF\xBF")

  # Mininum and maximum three byte characters
  assert_equal("\u0800", "\xE0\xA0\x80")
  assert_equal("\uFFFF", "\xEF\xBF\xBF")

  # Four byte characters require the \U notation
end

assert('braced \u notation test') do
  # Mininum and maximum one byte characters
  assert_equal("\u{0000}", "\x00")
  assert_equal("\u{007F}", "\x7F")

  # Mininum and maximum two byte characters
  assert_equal("\u{0080}", "\xC2\x80")
  assert_equal("\u{07FF}", "\xDF\xBF")

  # Mininum and maximum three byte characters
  assert_equal("\u{0800}", "\xE0\xA0\x80")
  assert_equal("\u{FFFF}", "\xEF\xBF\xBF")

  # Mininum and maximum four byte characters
  assert_equal("\u{10000}",  "\xF0\x90\x80\x80")
  assert_equal("\u{10FFFF}", "\xF4\x8F\xBF\xBF")
end