Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: utils/tests/pub/path/path_windows_test.dart

Issue 11553005: Move path-manipulation code from io.dart into path.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: utils/tests/pub/path/path_windows_test.dart
diff --git a/utils/tests/pub/path/path_windows_test.dart b/utils/tests/pub/path/path_windows_test.dart
index 1861a675b981ccdf723b6bea0b375bf6db159b96..232fe34e4ed31b6a1cabba749275f0d3f7769930 100644
--- a/utils/tests/pub/path/path_windows_test.dart
+++ b/utils/tests/pub/path/path_windows_test.dart
@@ -35,6 +35,30 @@ main() {
expect(builder.extension(r'a.b/c'), r'');
});
+ test('rootOf', () {
+ expect(builder.rootOf(''), null);
+ expect(builder.rootOf('a'), null);
+ expect(builder.rootOf(r'a\b'), null);
+ expect(builder.rootOf(r'C:\a\c'), 'C:\\');
Bob Nystrom 2012/12/12 00:01:20 Can you use raw strings for these? Here and below.
nweiz 2012/12/12 00:50:37 It screws with my editor to have a string ending w
Bob Nystrom 2012/12/12 01:02:13 It screws up my editor too (I need to fix the subl
nweiz 2012/12/12 02:45:57 Done.
+ expect(builder.rootOf('C:\\'), 'C:\\');
+ expect(builder.rootOf('C:/'), 'C:/');
+
+ // TODO(nweiz): enable this once issue 7323 is fixed.
+ // expect(builder.rootOf(r'\\server\a\b'), '\\\\server\\');
+ });
+
+ test('dirname', () {
+ expect(builder.dirname(r''), '.');
+ expect(builder.dirname(r'a'), '.');
+ expect(builder.dirname(r'a\b'), 'a');
+ expect(builder.dirname(r'a\b\c'), r'a\b');
+ expect(builder.dirname(r'a\b.c'), 'a');
+ expect(builder.dirname('a\\'), 'a');
+ expect(builder.dirname('a/'), 'a');
+ expect(builder.dirname(r'a\.'), 'a');
+ expect(builder.dirname(r'a\b/c'), r'a\b');
+ });
+
test('basename', () {
expect(builder.basename(r''), '');
expect(builder.basename(r'a'), 'a');
@@ -123,6 +147,38 @@ main() {
expect(builder.join('a', r'c:\b', 'c', 'd'), r'c:\b\c\d');
expect(builder.join('a', r'\\b', r'\\c', 'd'), r'\\c\d');
});
+
+ test('ignores trailing nulls', () {
+ expect(builder.join('a', null), equals('a'));
+ expect(builder.join('a', 'b', 'c', null, null), equals(r'a\b\c'));
+ });
+
+ test('disallows intermediate nulls', () {
+ expect(() => builder.join('a', null, 'b'), throwsArgumentError);
+ expect(() => builder.join(null, 'a'), throwsArgumentError);
+ });
+ });
+
+ group('split', () {
+ test('simple cases', () {
+ expect(builder.split('foo'), equals(['foo']));
+ expect(builder.split(r'foo\bar'), equals(['foo', 'bar']));
+ expect(builder.split(r'foo\bar\baz'), equals(['foo', 'bar', 'baz']));
+ expect(builder.split(r'foo\..\bar\.\baz'),
+ equals(['foo', '..', 'bar', '.', 'baz']));
+ expect(builder.split(r'foo\\bar\\\baz'), equals(['foo', 'bar', 'baz']));
+ expect(builder.split(r'foo\/\baz'), equals(['foo', 'baz']));
+ });
+
+ test('includes the root for absolute paths', () {
+ expect(builder.split(r'C:\foo\bar\baz'), equals(['C:\\', 'foo', 'bar', 'baz']));
Bob Nystrom 2012/12/12 00:01:20 Long line.
nweiz 2012/12/12 00:50:37 Done.
+ expect(builder.split(r'C:\\'), equals(['C:\\']));
+
+ // TODO(nweiz): enable these once issue 7323 is fixed.
+ // expect(builder.split(r'\\server\foo\bar\baz'),
+ // equals(['\\\\server\\', 'foo', 'bar', 'baz']));
+ // expect(builder.split('\\\\server\\'), equals(['\\\\server\\']));
+ });
});
group('normalize', () {
@@ -259,6 +315,10 @@ main() {
expect(r.relative(r'C:\dir.ext\file'), 'file');
});
+ test('with a root parameter', () {
+ expect(builder.relative(r'C:\foo\bar\baz', to: r'C:\foo\bar'), equals('baz'));
Bob Nystrom 2012/12/12 00:01:20 Long line.
nweiz 2012/12/12 00:50:37 Done.
+ });
+
test('given absolute with different root prefix', () {
expect(builder.relative(r'D:\a\b'), r'D:\a\b');
expect(builder.relative(r'\\a\b'), r'\\a\b');
« utils/tests/pub/path/path_posix_test.dart ('K') | « utils/tests/pub/path/path_posix_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698