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

Unified Diff: recipes/test/core/strings/splitting_strings_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/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'));
+ });
+ });
+}
« no previous file with comments | « recipes/test/core/strings/removing_leading_trailing_whitespace_test.dart ('k') | recipes/test/core/strings/strings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698