File: unicode.rb

package info (click to toggle)
mruby 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: ansic: 51,933; ruby: 29,510; yacc: 7,077; cpp: 517; makefile: 51; sh: 42
file content (39 lines) | stat: -rw-r--r-- 1,118 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
36
37
38
39
# Test of the \u notation

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

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

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

  # Four byte characters require the \U notation
end

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

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

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

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

assert('braced multiple \u notation test') do
  assert_equal("ABC", "\u{41 42 43}")
end