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

Unified Diff: test/windows_test.dart

Issue 1468343002: Improve the performance of isWithin(). (Closed) Base URL: git@github.com:dart-lang/path@master
Patch Set: remove -dev Created 5 years, 1 month 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
« lib/src/context.dart ('K') | « test/url_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/windows_test.dart
diff --git a/test/windows_test.dart b/test/windows_test.dart
index a32f1fec15458f96a2f6f02b6fe3f10cb91a0494..1bcad510ab3fb5cd3b8eaff3df38483b09476dfa 100644
--- a/test/windows_test.dart
+++ b/test/windows_test.dart
@@ -537,6 +537,28 @@ main() {
expect(context.isWithin(r'baz', r'C:\root\path\bang\baz'), isFalse);
});
+ test('complex cases', () {
+ expect(context.isWithin(r'foo\.\bar', r'foo\bar\baz'), isTrue);
+ expect(context.isWithin(r'foo\\bar', r'foo\bar\baz'), isTrue);
+ expect(context.isWithin(r'foo\qux\..\bar', r'foo\bar\baz'), isTrue);
+ expect(context.isWithin(r'foo\bar', r'foo\bar\baz\..\..'), isFalse);
+ expect(context.isWithin(r'foo\bar', r'foo\bar\\\'), isFalse);
+ expect(context.isWithin(r'foo\.bar', r'foo\.bar\baz'), isTrue);
+ expect(context.isWithin(r'foo\.\bar', r'foo\.bar\baz'), isFalse);
+ expect(context.isWithin(r'foo\..bar', r'foo\..bar\baz'), isTrue);
+ expect(context.isWithin(r'C:\', 'C:/foo'), isTrue);
+ expect(context.isWithin(r'C:\', r'D:\foo'), isFalse);
+ expect(context.isWithin(r'C:\', r'\\foo\bar'), isFalse);
+ });
+
+ test('with root-relative paths', () {
+ expect(context.isWithin(r'\foo', r'C:\foo\bar'), isTrue);
+ expect(context.isWithin(r'C:\foo', r'\foo\bar'), isTrue);
+ expect(context.isWithin(r'\root', r'foo\bar'), isTrue);
+ expect(context.isWithin(r'foo', r'\root\path\foo\bar'), isTrue);
+ expect(context.isWithin(r'\foo', r'\foo\bar'), isTrue);
+ });
+
test('from a relative root', () {
var r = new path.Context(style: path.Style.windows, current: r'foo\bar');
expect(r.isWithin('.', r'a\b\c'), isTrue);
« lib/src/context.dart ('K') | « test/url_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698