OLD | NEW |
(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 } |
OLD | NEW |