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

Unified Diff: test/url_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
Index: test/url_test.dart
diff --git a/test/url_test.dart b/test/url_test.dart
index 1188129f396924998191fe972cf1b2b3e925f487..5a5d57b111e4ede44c38d26aedb1b41f4440c205 100644
--- a/test/url_test.dart
+++ b/test/url_test.dart
@@ -629,6 +629,29 @@ main() {
isFalse);
});
+ test('complex cases', () {
+ expect(context.isWithin('foo/./bar', 'foo/bar/baz'), isTrue);
+ expect(context.isWithin('foo//bar', 'foo/bar/baz'), isTrue);
+ expect(context.isWithin('foo/qux/../bar', 'foo/bar/baz'), isTrue);
+ expect(context.isWithin('foo/bar', 'foo/bar/baz/../..'), isFalse);
+ expect(context.isWithin('foo/bar', 'foo/bar///'), isFalse);
+ expect(context.isWithin('foo/.bar', 'foo/.bar/baz'), isTrue);
+ expect(context.isWithin('foo/./bar', 'foo/.bar/baz'), isFalse);
+ expect(context.isWithin('foo/..bar', 'foo/..bar/baz'), isTrue);
+ expect(context.isWithin('http://example.org/', 'http://example.com/foo'),
+ isFalse);
+ expect(context.isWithin('http://example.org/', 'http://dartlang.org/foo'),
+ isFalse);
+ });
+
+ test('with root-relative paths', () {
+ expect(context.isWithin('/foo', 'http://dartlang.org/foo/bar'), isTrue);
+ expect(context.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue);
+ expect(context.isWithin('/root', 'foo/bar'), isTrue);
+ expect(context.isWithin('foo', '/root/path/foo/bar'), isTrue);
+ expect(context.isWithin('/foo', '/foo/bar'), isTrue);
+ });
+
test('from a relative root', () {
var r = new path.Context(style: path.Style.url, current: 'foo/bar');
expect(r.isWithin('.', 'a/b/c'), isTrue);
« lib/src/context.dart ('K') | « test/posix_test.dart ('k') | test/windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698