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

Unified Diff: recipes/test/core/strings/processing_a_string_one_character_test.dart

Issue 12335109: Strings recipes for the Dart Cookbook (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Total rewrite of string recipes. 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 side-by-side diff with in-line comments
Download patch
Index: recipes/test/core/strings/processing_a_string_one_character_test.dart
diff --git a/recipes/test/core/strings/processing_a_string_one_character_test.dart b/recipes/test/core/strings/processing_a_string_one_character_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..69f89aa4ab35cc9bae6e9191385b6a05f5f5bd61
--- /dev/null
+++ b/recipes/test/core/strings/processing_a_string_one_character_test.dart
@@ -0,0 +1,30 @@
+library processing_a_string_one_character_test;
+
+import 'package:unittest/unittest.dart';
+
+void main() {
+
+
+ group('processing a string one character at a time', () {
+ var smileyFace = '\u263A';
+ var happy = 'I am $smileyFace';
+ var clef = '\u{1F3BC}';
+
+ test('on rune boundary', () {
+ expect("Dart".runes.map((rune) => '*${new String.fromCharCode(rune)}*').toList(),
+ equals(['*D*', '*a*', '*r*', '*t*']));
+
+ expect(happy.runes.map((rune) => [rune, new String.fromCharCode(rune)]).toList(),
+ equals([ [73, 'I'], [32, ' '], [97, 'a'], [109, 'm'], [32, ' '], [9786, '☺'] ]));
+
+ expect(clef.runes.map((rune) => new String.fromCharCode(rune)).toList(),
+ equals(['\u{1F3BC}']));
+ });
+
+ test('on code-unit boundary', () {
+ expect('Dart'.split(''), equals(['D', 'a', 'r', 't']));
+ expect(smileyFace.split('').length, equals(1));
+ expect(clef.split('').length, equals(2));
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698