1 | # Test of the \u notation
|
---|
2 |
|
---|
3 | assert('bare \u notation test') do
|
---|
4 | # Mininum and maximum one byte characters
|
---|
5 | assert_equal("\x00", "\u0000")
|
---|
6 | assert_equal("\x7F", "\u007F")
|
---|
7 |
|
---|
8 | # Mininum and maximum two byte characters
|
---|
9 | assert_equal("\xC2\x80", "\u0080")
|
---|
10 | assert_equal("\xDF\xBF", "\u07FF")
|
---|
11 |
|
---|
12 | # Mininum and maximum three byte characters
|
---|
13 | assert_equal("\xE0\xA0\x80", "\u0800")
|
---|
14 | assert_equal("\xEF\xBF\xBF", "\uFFFF")
|
---|
15 |
|
---|
16 | # Four byte characters require the \U notation
|
---|
17 | end
|
---|
18 |
|
---|
19 | assert('braced \u notation test') do
|
---|
20 | # Mininum and maximum one byte characters
|
---|
21 | assert_equal("\x00", "\u{0000}")
|
---|
22 | assert_equal("\x7F", "\u{007F}")
|
---|
23 |
|
---|
24 | # Mininum and maximum two byte characters
|
---|
25 | assert_equal("\xC2\x80", "\u{0080}")
|
---|
26 | assert_equal("\xDF\xBF", "\u{07FF}")
|
---|
27 |
|
---|
28 | # Mininum and maximum three byte characters
|
---|
29 | assert_equal("\xE0\xA0\x80", "\u{0800}")
|
---|
30 | assert_equal("\xEF\xBF\xBF", "\u{FFFF}")
|
---|
31 |
|
---|
32 | # Mininum and maximum four byte characters
|
---|
33 | assert_equal("\xF0\x90\x80\x80", "\u{10000}")
|
---|
34 | assert_equal("\xF4\x8F\xBF\xBF", "\u{10FFFF}")
|
---|
35 | end
|
---|
36 |
|
---|
37 | assert('braced multiple \u notation test') do
|
---|
38 | assert_equal("ABC", "\u{41 42 43}")
|
---|
39 | end
|
---|