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..40bc83694eedeb336a1dba8ac62a301d32fa5f8f |
--- /dev/null |
+++ b/recipes/test/core/strings/calculating_the_length_test.dart |
@@ -0,0 +1,28 @@ |
+library calculating_the_length_test; |
+ |
+import 'package:unittest/unittest.dart'; |
+ |
+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)); |
+ }); |
+ }); |
+} |