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

Unified Diff: test/posix_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') | « pubspec.yaml ('k') | test/url_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/posix_test.dart
diff --git a/test/posix_test.dart b/test/posix_test.dart
index d6d7a90e99030bc17cba0c4cc06200191625af15..2cdda23fc8c99e083b474aef5182522f6bc16a5a 100644
--- a/test/posix_test.dart
+++ b/test/posix_test.dart
@@ -419,6 +419,17 @@ main() {
expect(context.isWithin('baz', '/root/path/bang/baz'), 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);
+ });
+
test('from a relative root', () {
var r = new path.Context(style: path.Style.posix, current: 'foo/bar');
expect(r.isWithin('.', 'a/b/c'), isTrue);
« lib/src/context.dart ('K') | « pubspec.yaml ('k') | test/url_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698