Index: pkg/path/test/posix_test.dart |
diff --git a/pkg/path/test/posix_test.dart b/pkg/path/test/posix_test.dart |
index 1156379a8555dc574f839c8523fdeb277f4baa0d..5bb38d0321907ff6a0581d6e588c8f166a12d31e 100644 |
--- a/pkg/path/test/posix_test.dart |
+++ b/pkg/path/test/posix_test.dart |
@@ -411,6 +411,27 @@ main() { |
}); |
}); |
+ group('isWithin', () { |
+ test('simple cases', () { |
+ expect(builder.isWithin('foo/bar', 'foo/bar'), isFalse); |
+ expect(builder.isWithin('foo/bar', 'foo/bar/baz'), isTrue); |
+ expect(builder.isWithin('foo/bar', 'foo/baz'), isFalse); |
+ expect(builder.isWithin('foo/bar', '../path/foo/bar/baz'), isTrue); |
+ expect(builder.isWithin('/', '/foo/bar'), isTrue); |
+ expect(builder.isWithin('baz', '/root/path/baz/bang'), isTrue); |
+ expect(builder.isWithin('baz', '/root/path/bang/baz'), isFalse); |
+ }); |
+ |
+ test('from a relative root', () { |
+ var r = new path.Builder(style: path.Style.posix, root: 'foo/bar'); |
+ expect(builder.isWithin('.', 'a/b/c'), isTrue); |
+ expect(builder.isWithin('.', '../a/b/c'), isFalse); |
+ expect(builder.isWithin('.', '../../a/foo/b/c'), isFalse); |
+ expect(builder.isWithin('/', '/baz/bang'), isTrue); |
+ expect(builder.isWithin('.', '/baz/bang'), isFalse); |
+ }); |
+ }); |
+ |
group('resolve', () { |
test('allows up to seven parts', () { |
expect(builder.resolve('a'), '/root/path/a'); |