OLD | NEW |
(Empty) | |
| 1 library subscripting_a_string_test; |
| 2 |
| 3 import 'package:unittest/unittest.dart'; |
| 4 |
| 5 void main() { |
| 6 group('getting the character at a specific index', () { |
| 7 group("with non-BMP symbol", () { |
| 8 test('with non-BMP symbol', () { |
| 9 var coffee = '\u{1F375}'; |
| 10 expect(coffee.runes.toList(), equals([127861])); |
| 11 expect(new String.fromCharCode(coffee.runes.first), |
| 12 equals(coffee)); |
| 13 // Cannot use coffee[0] directly. |
| 14 expect(coffee.codeUnits.first, equals(55356)); |
| 15 expect(coffee.codeUnits.toList()[0], equals(55356)); |
| 16 }); |
| 17 }); |
| 18 |
| 19 group('with BMP symbol', () { |
| 20 |
| 21 test('with BMP symbols', () { |
| 22 expect('Dart'[0], equals('D')); |
| 23 |
| 24 var hearts = '\u2661'; |
| 25 expect(hearts[0], equals('\u2661')); |
| 26 }); |
| 27 }); |
| 28 }); |
| 29 } |
OLD | NEW |