OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library path.test.windows_test; | 5 library path.test.windows_test; |
6 | 6 |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
9 | 9 |
10 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 expect(context.isWithin(r'foo\bar', r'..\path\foo\bar\baz'), isTrue); | 530 expect(context.isWithin(r'foo\bar', r'..\path\foo\bar\baz'), isTrue); |
531 expect(context.isWithin(r'C:\', r'C:\foo\bar'), isTrue); | 531 expect(context.isWithin(r'C:\', r'C:\foo\bar'), isTrue); |
532 expect(context.isWithin(r'C:\', r'D:\foo\bar'), isFalse); | 532 expect(context.isWithin(r'C:\', r'D:\foo\bar'), isFalse); |
533 expect(context.isWithin(r'C:\', r'\foo\bar'), isTrue); | 533 expect(context.isWithin(r'C:\', r'\foo\bar'), isTrue); |
534 expect(context.isWithin(r'C:\foo', r'\foo\bar'), isTrue); | 534 expect(context.isWithin(r'C:\foo', r'\foo\bar'), isTrue); |
535 expect(context.isWithin(r'C:\foo', r'\bar\baz'), isFalse); | 535 expect(context.isWithin(r'C:\foo', r'\bar\baz'), isFalse); |
536 expect(context.isWithin(r'baz', r'C:\root\path\baz\bang'), isTrue); | 536 expect(context.isWithin(r'baz', r'C:\root\path\baz\bang'), isTrue); |
537 expect(context.isWithin(r'baz', r'C:\root\path\bang\baz'), isFalse); | 537 expect(context.isWithin(r'baz', r'C:\root\path\bang\baz'), isFalse); |
538 }); | 538 }); |
539 | 539 |
| 540 test('complex cases', () { |
| 541 expect(context.isWithin(r'foo\.\bar', r'foo\bar\baz'), isTrue); |
| 542 expect(context.isWithin(r'foo\\bar', r'foo\bar\baz'), isTrue); |
| 543 expect(context.isWithin(r'foo\qux\..\bar', r'foo\bar\baz'), isTrue); |
| 544 expect(context.isWithin(r'foo\bar', r'foo\bar\baz\..\..'), isFalse); |
| 545 expect(context.isWithin(r'foo\bar', r'foo\bar\\\'), isFalse); |
| 546 expect(context.isWithin(r'foo\.bar', r'foo\.bar\baz'), isTrue); |
| 547 expect(context.isWithin(r'foo\.\bar', r'foo\.bar\baz'), isFalse); |
| 548 expect(context.isWithin(r'foo\..bar', r'foo\..bar\baz'), isTrue); |
| 549 expect(context.isWithin(r'C:\', 'C:/foo'), isTrue); |
| 550 expect(context.isWithin(r'C:\', r'D:\foo'), isFalse); |
| 551 expect(context.isWithin(r'C:\', r'\\foo\bar'), isFalse); |
| 552 }); |
| 553 |
| 554 test('with root-relative paths', () { |
| 555 expect(context.isWithin(r'\foo', r'C:\foo\bar'), isTrue); |
| 556 expect(context.isWithin(r'C:\foo', r'\foo\bar'), isTrue); |
| 557 expect(context.isWithin(r'\root', r'foo\bar'), isTrue); |
| 558 expect(context.isWithin(r'foo', r'\root\path\foo\bar'), isTrue); |
| 559 expect(context.isWithin(r'\foo', r'\foo\bar'), isTrue); |
| 560 }); |
| 561 |
540 test('from a relative root', () { | 562 test('from a relative root', () { |
541 var r = new path.Context(style: path.Style.windows, current: r'foo\bar'); | 563 var r = new path.Context(style: path.Style.windows, current: r'foo\bar'); |
542 expect(r.isWithin('.', r'a\b\c'), isTrue); | 564 expect(r.isWithin('.', r'a\b\c'), isTrue); |
543 expect(r.isWithin('.', r'..\a\b\c'), isFalse); | 565 expect(r.isWithin('.', r'..\a\b\c'), isFalse); |
544 expect(r.isWithin('.', r'..\..\a\foo\b\c'), isFalse); | 566 expect(r.isWithin('.', r'..\..\a\foo\b\c'), isFalse); |
545 expect(r.isWithin(r'C:\', r'C:\baz\bang'), isTrue); | 567 expect(r.isWithin(r'C:\', r'C:\baz\bang'), isTrue); |
546 expect(r.isWithin('.', r'C:\baz\bang'), isFalse); | 568 expect(r.isWithin('.', r'C:\baz\bang'), isFalse); |
547 }); | 569 }); |
548 }); | 570 }); |
549 | 571 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 689 |
668 test('with a root-relative URI', () { | 690 test('with a root-relative URI', () { |
669 expect(context.prettyUri('/D:/a/b'), r'D:\a\b'); | 691 expect(context.prettyUri('/D:/a/b'), r'D:\a\b'); |
670 }); | 692 }); |
671 | 693 |
672 test('with a Uri object', () { | 694 test('with a Uri object', () { |
673 expect(context.prettyUri(Uri.parse('a/b')), r'a\b'); | 695 expect(context.prettyUri(Uri.parse('a/b')), r'a\b'); |
674 }); | 696 }); |
675 }); | 697 }); |
676 } | 698 } |
OLD | NEW |