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

Unified Diff: recipes/test/core/strings/calculating_the_length_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
« no previous file with comments | « recipes/test/core/core_test.dart ('k') | recipes/test/core/strings/changing_string_case_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipes/test/core/strings/calculating_the_length_test.dart
diff --git a/recipes/test/core/strings/calculating_the_length_test.dart b/recipes/test/core/strings/calculating_the_length_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..81210294a4956a7cbb4b2930fcb5d52d58a160df
--- /dev/null
+++ b/recipes/test/core/strings/calculating_the_length_test.dart
@@ -0,0 +1,39 @@
+library calculating_the_length_test;
+
+import 'package:unittest/unittest.dart';
+
+print(obj) {
+ return obj;
+}
+
+void main() {
+ group('calculating the length of a string', () {
+
+ var hearts = '\u2661';
+
+ test('that contains only BMP symbols', () {
+ expect('I love music'.length, equals(12));
+ expect('I love music'.runes.length, equals(12));
+
+ expect(hearts.length, equals(1));
+ expect(hearts.runes.length, equals(1));
+ });
+
+ test('that contains non-BMP symbols', () {
+ var clef = '\u{1F3BC}';
+ expect(clef.length, equals(2));
+ expect(clef.runes.length, equals(1));
+
+ var music = 'I $hearts $clef';
+ expect(music.length, equals(6));
+ expect(music.runes.length, equals(5));
+ });
+
+ test('that has superimposed characters', () {
+ var name = 'Ameli\u00E9'; // 'AmeliƩ'
+ var anotherName = 'Ameli\u0065\u0301'; // 'AmeliƩ'
+ expect(print(name.length), equals(6));
+ expect(print(anotherName.length), equals(7));
+ });
+ });
+}
« no previous file with comments | « recipes/test/core/core_test.dart ('k') | recipes/test/core/strings/changing_string_case_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698