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

Unified Diff: recipes/test/core/strings/subscripting_a_string_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 side-by-side diff with in-line comments
Download patch
Index: recipes/test/core/strings/subscripting_a_string_test.dart
diff --git a/recipes/test/core/strings/subscripting_a_string_test.dart b/recipes/test/core/strings/subscripting_a_string_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b2e4c748b6fbba82563f4428acc92249760f03e9
--- /dev/null
+++ b/recipes/test/core/strings/subscripting_a_string_test.dart
@@ -0,0 +1,29 @@
+library subscripting_a_string_test;
+
+import 'package:unittest/unittest.dart';
+
+void main() {
+ group('getting the character at a specific index', () {
+ group("with non-BMP symbol", () {
+ test('with non-BMP symbol', () {
+ var coffee = '\u{1F375}';
+ expect(coffee.runes.toList(), equals([127861]));
+ expect(new String.fromCharCode(coffee.runes.first),
+ equals(coffee));
+ // Cannot use coffee[0] directly.
+ expect(coffee.codeUnits.first, equals(55356));
+ expect(coffee.codeUnits.toList()[0], equals(55356));
+ });
+ });
+
+ group('with BMP symbol', () {
+
+ test('with BMP symbols', () {
+ expect('Dart'[0], equals('D'));
+
+ var hearts = '\u2661';
+ expect(hearts[0], equals('\u2661'));
+ });
+ });
+ });
+}
« no previous file with comments | « recipes/test/core/strings/strings_test.dart ('k') | recipes/test/core/strings/substituting_strings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698