Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library test.engine.utilities.absolute_path; | |
| 6 | |
| 7 import 'package:analyzer/src/util/absolute_path.dart'; | |
| 8 import 'package:unittest/unittest.dart'; | |
| 9 | |
| 10 import '../../reflective_tests.dart'; | |
| 11 import '../../utils.dart'; | |
| 12 | |
| 13 main() { | |
| 14 initializeTestEnvironment(); | |
| 15 runReflectiveTests(AbsolutePathContextPosixTest); | |
| 16 runReflectiveTests(AbsolutePathContextWindowsTest); | |
| 17 } | |
| 18 | |
| 19 @reflectiveTest | |
| 20 class AbsolutePathContextPosixTest { | |
| 21 AbsolutePathContext context = new AbsolutePathContext(r'/'); | |
| 22 | |
| 23 void test_append() { | |
| 24 expect(context.append(r'/path/to', r'foo.dart'), r'/path/to/foo.dart'); | |
| 25 } | |
| 26 | |
| 27 void test_basename() { | |
| 28 expect(context.basename(r'/path/to/foo.dart'), r'foo.dart'); | |
| 29 expect(context.basename(r'/path/to'), r'to'); | |
| 30 } | |
| 31 | |
| 32 void test_dirname() { | |
| 33 expect(context.dirname(r'/path/to/foo.dart'), r'/path/to'); | |
| 34 expect(context.dirname(r'/path/to'), r'/path'); | |
|
Brian Wilkerson
2015/11/14 17:30:25
expect(context.dirname(r'/path'), r'/');
expect(co
scheglov
2015/11/14 22:40:13
Done.
| |
| 35 } | |
| 36 | |
| 37 void test_isWithin() { | |
| 38 expect(context.isWithin(r'/root/path', r'/root/path/a'), isTrue); | |
| 39 expect(context.isWithin(r'/root/path', r'/root/other'), isFalse); | |
| 40 expect(context.isWithin(r'/root/path', r'/root/path'), isFalse); | |
| 41 } | |
| 42 | |
| 43 void test_relative() { | |
| 44 expect( | |
| 45 context.relative(r'/root/path/a/b.dart', r'/root/path'), r'a/b.dart'); | |
| 46 expect(context.relative(r'/root/other.dart', r'/root/path'), isNull); | |
| 47 } | |
| 48 | |
| 49 void test_split() { | |
| 50 expect(context.split(r'/path/to/foo'), [r'', r'path', r'to', r'foo']); | |
| 51 expect(context.split(r'/path'), [r'', r'path']); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 @reflectiveTest | |
| 56 class AbsolutePathContextWindowsTest { | |
| 57 AbsolutePathContext context = new AbsolutePathContext(r'\'); | |
| 58 | |
| 59 void test_append() { | |
| 60 expect(context.append(r'C:\path\to', r'foo.dart'), r'C:\path\to\foo.dart'); | |
| 61 } | |
| 62 | |
| 63 void test_basename() { | |
| 64 expect(context.basename(r'C:\path\to\foo.dart'), r'foo.dart'); | |
| 65 expect(context.basename(r'C:\path\to'), r'to'); | |
| 66 } | |
| 67 | |
| 68 void test_dirname() { | |
| 69 expect(context.dirname(r'C:\path\to\foo.dart'), r'C:\path\to'); | |
| 70 expect(context.dirname(r'C:\path\to'), r'C:\path'); | |
|
Brian Wilkerson
2015/11/14 17:30:25
expect(context.dirname(r'C:\path'), r'C:\');
expec
scheglov
2015/11/14 22:40:13
Done.
| |
| 71 } | |
| 72 | |
| 73 void test_isWithin() { | |
| 74 expect(context.isWithin(r'C:\root\path', r'C:\root\path\a'), isTrue); | |
| 75 expect(context.isWithin(r'C:\root\path', r'C:\root\other'), isFalse); | |
| 76 expect(context.isWithin(r'C:\root\path', r'C:\root\path'), isFalse); | |
| 77 } | |
| 78 | |
| 79 void test_relative() { | |
| 80 expect(context.relative(r'C:\root\path\a\b.dart', r'C:\root\path'), | |
| 81 r'a\b.dart'); | |
| 82 expect(context.relative(r'C:\root\other.dart', r'C:\root\path'), isNull); | |
| 83 } | |
| 84 | |
| 85 void test_split() { | |
| 86 expect(context.split(r'C:\path\to\foo'), [r'C:', r'path', r'to', r'foo']); | |
| 87 expect(context.split(r'C:\path'), [r'C:', r'path']); | |
| 88 } | |
| 89 } | |
| OLD | NEW |