| Index: recipes/test/core/strings/finding_regexp_matches_test.dart
|
| diff --git a/recipes/test/core/strings/finding_regexp_matches_test.dart b/recipes/test/core/strings/finding_regexp_matches_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..757c69cfef5a668c086f3e4077e961e9bbc571bd
|
| --- /dev/null
|
| +++ b/recipes/test/core/strings/finding_regexp_matches_test.dart
|
| @@ -0,0 +1,27 @@
|
| +library finding_regexp_matches;
|
| +
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +void main() {
|
| + group('finding regExp matches', () {
|
| + var neverEatingThat = 'Not with a fox, not in a box';
|
| + var regExp = new RegExp(r'[fb]ox');
|
| +
|
| + test('using allMatches()', () {
|
| + List matches = regExp.allMatches(neverEatingThat);
|
| + expect(matches.map((match) => match.group(0)).toList(), equals(['fox', 'box']));
|
| + // Finding the number of occurences of a subneverEatingThat.
|
| + expect(matches.length, equals(2));
|
| + });
|
| +
|
| + test('using firstMatch()', () {
|
| + expect(regExp.firstMatch(neverEatingThat).group(0), equals('fox'));
|
| + });
|
| +
|
| + test('using neverEatingThatMatch', () {
|
| + expect(regExp.stringMatch(neverEatingThat), equals('fox'));
|
| + expect(regExp.stringMatch('I like bagels and lox'), isNull);
|
| + });
|
| + });
|
| +}
|
| +
|
|
|