OLD | NEW |
(Empty) | |
| 1 library handling_extended_characters_test; |
| 2 |
| 3 import 'package:unittest/unittest.dart'; |
| 4 |
| 5 print(obj) => obj; |
| 6 |
| 7 void main() { |
| 8 var clef = '\u{1F3BC}'; |
| 9 group('creating an extended character', () { |
| 10 test('using a rune', () { |
| 11 expect(print(clef), equals('🎼')); |
| 12 }); |
| 13 }); |
| 14 |
| 15 group('accessing runes and code units', () { |
| 16 test('', () { |
| 17 expect(clef.codeUnits.map((codeUnit) => codeUnit.toRadixString(16)), equal
s(['d83c', 'dfbc'])); |
| 18 expect(clef.runes.map((rune) => rune.toRadixString(16)).toList(), equals([
'1f3bc'])); |
| 19 }); |
| 20 }); |
| 21 |
| 22 group('accessing length', () { |
| 23 test('', () { |
| 24 expect(print(clef.length), equals(2)); |
| 25 expect(print(clef.codeUnits.length), equals(2)); |
| 26 expect(print(clef.runes.length), equals(1)); |
| 27 }); |
| 28 }); |
| 29 |
| 30 group('subscripting', () { |
| 31 test('', () { |
| 32 expect(print(clef.runes.first.toRadixString(16)), equals('1f3bc')); |
| 33 expect(print(clef.runes.toList()[0].toRadixString(16)), equals('1f3bc')); |
| 34 // This test will never pass because clef[0] is an illegal string. |
| 35 // expect(print(clef[0]), equals('?')); |
| 36 expect(print(clef.codeUnits[0]), equals(55356)); |
| 37 expect(clef.runes.toList()[0], equals(127932)); |
| 38 }); |
| 39 }); |
| 40 } |
| 41 |
OLD | NEW |