Index: recipes/test/core/strings/splitting_strings_test.dart |
diff --git a/recipes/test/core/strings/splitting_strings_test.dart b/recipes/test/core/strings/splitting_strings_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..754dd6995472735e7278e102c8d2b4cd7de593e5 |
--- /dev/null |
+++ b/recipes/test/core/strings/splitting_strings_test.dart |
@@ -0,0 +1,33 @@ |
+library splitting_strings_test; |
+ |
+import 'package:unittest/unittest.dart'; |
+ |
+void main() { |
+ group('splitting a string', () { |
+ var clef = '\u{1F3BC}'; |
+ var smileyFace = '\u263A'; |
+ var happy = 'I am $smileyFace'; |
+ |
+ group('using split(string)', () { |
+ test('on code-unit boundary', () { |
+ expect(happy.split(' '), equals(['I', 'am', '☺'])); |
+ }); |
+ }); |
+ |
+ group('using split(regExp)', () { |
+ var nums = '2/7 3 4/5 3~/5'; |
+ var numsRegExp = new RegExp(r'(\s|/|~/)'); |
+ test('', () { |
+ expect(nums.split(numsRegExp), |
+ equals(['2', '7', '3', '4', '5', '3', '5'])); |
+ }); |
+ }); |
+ |
+ group('using splitMapJoin(regExp)', () { |
+ expect('Eats SHOOTS leaves'.splitMapJoin((new RegExp(r'SHOOTS')), |
+ onMatch: (m) => '*${m.group(0).toLowerCase()}*', |
+ onNonMatch: (n) => n.toUpperCase() |
+ ), equals('EATS *shoots* LEAVES')); |
+ }); |
+ }); |
+} |