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

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

Issue 12335109: Strings recipes for the Dart Cookbook (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Fixed typos. Created 7 years, 10 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_strings_test.dart
diff --git a/recipes/test/core/strings/subscripting_strings_test.dart b/recipes/test/core/strings/subscripting_strings_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9a548027519c588578357a31d212c70067a3e090
--- /dev/null
+++ b/recipes/test/core/strings/subscripting_strings_test.dart
@@ -0,0 +1,33 @@
+library subscripting_strings_test;
+
+import 'package:unittest/unittest.dart';
+
+void main() {
+ group('getting the character at a specific index', () {
+ group('with non-BMP symbol', () {
+ var hearts = '\u2661';
+
+ test('with BMP symbols', () {
+ expect('Dart'[0], equals('D'));
+ expect(hearts[0], equals('\u2661'));
+ });
+ });
+
+ group("with non-BMP symbol", () {
+ var coffee = '\u{1F375}';
+ var doughnuts = '\u{1F369}';
+ var healthFood = '$coffee and $doughnuts';
+ test('with non-BMP symbol', () {
+
+ // expect(healthFood[0], equals('?'));
+ expect(healthFood.slice(0, 2), equals(coffee));
+ });
+
+ test('', () {
+ expect(healthFood.runes.first, equals(127861));
+ expect(new String.fromCharCode(127861), equals(coffee));
+ expect(healthFood.codeUnits.first, equals(55356));
+ });
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698