Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: recipes/test/core/strings/handling_extended_characters_test.dart

Issue 12335109: Strings recipes for the Dart Cookbook (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Made most changes requested my Kathy. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « recipes/test/core/strings/finding_regexp_matches_test.dart ('k') | recipes/test/core/strings/incrementally_building_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698