Chromium Code Reviews| Index: pkg/analyzer/test/src/util/absolute_path_test.dart |
| diff --git a/pkg/analyzer/test/src/util/absolute_path_test.dart b/pkg/analyzer/test/src/util/absolute_path_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92a604490298798a3469c20736d1171d038b8aec |
| --- /dev/null |
| +++ b/pkg/analyzer/test/src/util/absolute_path_test.dart |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.engine.utilities.absolute_path; |
| + |
| +import 'package:analyzer/src/util/absolute_path.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import '../../reflective_tests.dart'; |
| +import '../../utils.dart'; |
| + |
| +main() { |
| + initializeTestEnvironment(); |
| + runReflectiveTests(AbsolutePathContextPosixTest); |
| + runReflectiveTests(AbsolutePathContextWindowsTest); |
| +} |
| + |
| +@reflectiveTest |
| +class AbsolutePathContextPosixTest { |
| + AbsolutePathContext context = new AbsolutePathContext(r'/'); |
| + |
| + void test_append() { |
| + expect(context.append(r'/path/to', r'foo.dart'), r'/path/to/foo.dart'); |
| + } |
| + |
| + void test_basename() { |
| + expect(context.basename(r'/path/to/foo.dart'), r'foo.dart'); |
| + expect(context.basename(r'/path/to'), r'to'); |
| + } |
| + |
| + void test_dirname() { |
| + expect(context.dirname(r'/path/to/foo.dart'), r'/path/to'); |
| + 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.
|
| + } |
| + |
| + void test_isWithin() { |
| + expect(context.isWithin(r'/root/path', r'/root/path/a'), isTrue); |
| + expect(context.isWithin(r'/root/path', r'/root/other'), isFalse); |
| + expect(context.isWithin(r'/root/path', r'/root/path'), isFalse); |
| + } |
| + |
| + void test_relative() { |
| + expect( |
| + context.relative(r'/root/path/a/b.dart', r'/root/path'), r'a/b.dart'); |
| + expect(context.relative(r'/root/other.dart', r'/root/path'), isNull); |
| + } |
| + |
| + void test_split() { |
| + expect(context.split(r'/path/to/foo'), [r'', r'path', r'to', r'foo']); |
| + expect(context.split(r'/path'), [r'', r'path']); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| +class AbsolutePathContextWindowsTest { |
| + AbsolutePathContext context = new AbsolutePathContext(r'\'); |
| + |
| + void test_append() { |
| + expect(context.append(r'C:\path\to', r'foo.dart'), r'C:\path\to\foo.dart'); |
| + } |
| + |
| + void test_basename() { |
| + expect(context.basename(r'C:\path\to\foo.dart'), r'foo.dart'); |
| + expect(context.basename(r'C:\path\to'), r'to'); |
| + } |
| + |
| + void test_dirname() { |
| + expect(context.dirname(r'C:\path\to\foo.dart'), r'C:\path\to'); |
| + 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.
|
| + } |
| + |
| + void test_isWithin() { |
| + expect(context.isWithin(r'C:\root\path', r'C:\root\path\a'), isTrue); |
| + expect(context.isWithin(r'C:\root\path', r'C:\root\other'), isFalse); |
| + expect(context.isWithin(r'C:\root\path', r'C:\root\path'), isFalse); |
| + } |
| + |
| + void test_relative() { |
| + expect(context.relative(r'C:\root\path\a\b.dart', r'C:\root\path'), |
| + r'a\b.dart'); |
| + expect(context.relative(r'C:\root\other.dart', r'C:\root\path'), isNull); |
| + } |
| + |
| + void test_split() { |
| + expect(context.split(r'C:\path\to\foo'), [r'C:', r'path', r'to', r'foo']); |
| + expect(context.split(r'C:\path'), [r'C:', r'path']); |
| + } |
| +} |