| 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.analyzer.src.util.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 expect(context.basename(r'/path'), r'path'); |
| 31 expect(context.basename(r'/'), r''); |
| 32 } |
| 33 |
| 34 void test_dirname() { |
| 35 expect(context.dirname(r'/path/to/foo.dart'), r'/path/to'); |
| 36 expect(context.dirname(r'/path/to'), r'/path'); |
| 37 expect(context.dirname(r'/path'), r'/'); |
| 38 expect(context.dirname(r'/'), r'/'); |
| 39 } |
| 40 |
| 41 void test_isWithin() { |
| 42 expect(context.isWithin(r'/root/path', r'/root/path/a'), isTrue); |
| 43 expect(context.isWithin(r'/root/path', r'/root/other'), isFalse); |
| 44 expect(context.isWithin(r'/root/path', r'/root/path'), isFalse); |
| 45 } |
| 46 |
| 47 void test_split() { |
| 48 expect(context.split(r'/path/to/foo'), [r'', r'path', r'to', r'foo']); |
| 49 expect(context.split(r'/path'), [r'', r'path']); |
| 50 } |
| 51 |
| 52 void test_suffix() { |
| 53 expect(context.suffix(r'/root/path/a/b.dart', r'/root/path'), r'a/b.dart'); |
| 54 expect(context.suffix(r'/root/other.dart', r'/root/path'), isNull); |
| 55 } |
| 56 } |
| 57 |
| 58 @reflectiveTest |
| 59 class AbsolutePathContextWindowsTest { |
| 60 AbsolutePathContext context = new AbsolutePathContext(r'\'); |
| 61 |
| 62 void test_append() { |
| 63 expect(context.append(r'C:\path\to', r'foo.dart'), r'C:\path\to\foo.dart'); |
| 64 } |
| 65 |
| 66 void test_basename() { |
| 67 expect(context.basename(r'C:\path\to\foo.dart'), r'foo.dart'); |
| 68 expect(context.basename(r'C:\path\to'), r'to'); |
| 69 expect(context.basename(r'C:\path'), r'path'); |
| 70 expect(context.basename(r'C:\'), r''); |
| 71 } |
| 72 |
| 73 void test_dirname() { |
| 74 expect(context.dirname(r'C:\path\to\foo.dart'), r'C:\path\to'); |
| 75 expect(context.dirname(r'C:\path\to'), r'C:\path'); |
| 76 expect(context.dirname(r'C:\path'), r'C:\'); |
| 77 expect(context.dirname(r'C:\'), r'C:\'); |
| 78 } |
| 79 |
| 80 void test_isWithin() { |
| 81 expect(context.isWithin(r'C:\root\path', r'C:\root\path\a'), isTrue); |
| 82 expect(context.isWithin(r'C:\root\path', r'C:\root\other'), isFalse); |
| 83 expect(context.isWithin(r'C:\root\path', r'C:\root\path'), isFalse); |
| 84 } |
| 85 |
| 86 void test_split() { |
| 87 expect(context.split(r'C:\path\to\foo'), [r'C:', r'path', r'to', r'foo']); |
| 88 expect(context.split(r'C:\path'), [r'C:', r'path']); |
| 89 } |
| 90 |
| 91 void test_suffix() { |
| 92 expect( |
| 93 context.suffix(r'C:\root\path\a\b.dart', r'C:\root\path'), r'a\b.dart'); |
| 94 expect(context.suffix(r'C:\root\other.dart', r'C:\root\path'), isNull); |
| 95 } |
| 96 } |
| OLD | NEW |