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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 library splitting_strings_test;
2
3 import 'package:unittest/unittest.dart';
4
5 void main() {
6 group('splitting a string', () {
7 var clef = '\u{1F3BC}';
8 var smileyFace = '\u263A';
9 var happy = 'I am $smileyFace';
10
11 group('using split(string)', () {
12 test('on code-unit boundary', () {
13 expect(happy.split(' '), equals(['I', 'am', '☺']));
14 });
15 });
16
17 group('using split(regExp)', () {
18 var nums = '2/7 3 4/5 3~/5';
19 var numsRegExp = new RegExp(r'(\s|/|~/)');
20 test('', () {
21 expect(nums.split(numsRegExp),
22 equals(['2', '7', '3', '4', '5', '3', '5']));
23 });
24 });
25
26 group('using splitMapJoin(regExp)', () {
27 expect('Eats SHOOTS leaves'.splitMapJoin((new RegExp(r'SHOOTS')),
28 onMatch: (m) => '*${m.group(0).toLowerCase()}*',
29 onNonMatch: (n) => n.toUpperCase()
30 ), equals('EATS *shoots* LEAVES'));
31 });
32 });
33 }
OLDNEW
« 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