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

Unified Diff: tests/corelib/string_pattern_test.dart

Issue 460613002: Add optional start index to Pattern.allMatches. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add extra test. Created 6 years, 4 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: tests/corelib/string_pattern_test.dart
diff --git a/tests/corelib/string_pattern_test.dart b/tests/corelib/string_pattern_test.dart
index c1bd241b7c9cca90e9ca540bae4348c4cdac478f..4229617ff1a7551f3c34dc3db6772e5aa25c75a9 100644
--- a/tests/corelib/string_pattern_test.dart
+++ b/tests/corelib/string_pattern_test.dart
@@ -15,6 +15,7 @@ main() {
testEmptyString();
testEmptyPatternAndString();
testMatchAsPrefix();
+ testAllMatchesStart();
}
testNoMatch() {
@@ -97,3 +98,15 @@ testMatchAsPrefix() {
Expect.throws(() => pattern.matchAsPrefix(str, -1));
Expect.throws(() => pattern.matchAsPrefix(str, 7));
}
+
+testAllMatchesStart() {
+ String p = "ass";
+ String s = "assassin";
+ Expect.equals(2, p.allMatches(s).length);
+ Expect.equals(2, p.allMatches(s, 0).length);
+ Expect.equals(1, p.allMatches(s, 1).length);
+ Expect.equals(0, p.allMatches(s, 4).length);
+ Expect.equals(0, p.allMatches(s, s.length).length);
+ Expect.throws(() => p.allMatches(s, -1));
+ Expect.throws(() => p.allMatches(s, s.length + 1));
+}

Powered by Google App Engine
This is Rietveld 408576698