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