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

Unified Diff: tests/standalone/io/path_test.dart

Issue 12662010: dart:io | Handle drive letters in Path.relativeTo on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reformat exception strings. Created 7 years, 9 months 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
« no previous file with comments | « sdk/lib/io/path_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/path_test.dart
diff --git a/tests/standalone/io/path_test.dart b/tests/standalone/io/path_test.dart
index 55c5031f658864b5c59af82ff36398706e26f008..895295745e997b94c0c078da7afe8ef752ee0c3e 100644
--- a/tests/standalone/io/path_test.dart
+++ b/tests/standalone/io/path_test.dart
@@ -13,6 +13,7 @@ void main() {
testJoinAppend();
testRelativeTo();
testWindowsShare();
+ testWindowsDrive();
}
void testBaseFunctions() {
@@ -301,3 +302,32 @@ void testWindowsShare() {
Expect.isTrue(directoryPath.isAbsolute);
Expect.isTrue(directoryPath.isWindowsShare);
}
+
+// Test that Windows drive information is handled correctly in relative
+// Path operations.
+void testWindowsDrive() {
+ // Windows drive information only makes sense on Windows.
+ if (Platform.operatingSystem != 'windows') return;
+ // Test that case of drive letters is ignored, and that drive letters
+ // are treated specially.
+ var CPath = new Path(r'C:\a\b\..\c');
+ var cPath = new Path(r'c:\a\b\d');
+ var C2Path = new Path(r'C:\a\b\d');
+ var C3Path = new Path(r'C:\a\b');
+ var C4Path = new Path(r'C:\');
+ var DPath = new Path(r'D:\a\b\d\e');
+ var NoPath = new Path(r'\a\b\c\.');
+
+ Expect.throws(() => CPath.relativeTo(DPath));
+ Expect.throws(() => CPath.relativeTo(NoPath));
+ Expect.throws(() => NoPath.relativeTo(CPath));
+ Expect.equals('../../c', CPath.relativeTo(cPath).toString());
+ Expect.equals('../b/d', cPath.relativeTo(CPath).toString());
+ Expect.equals('.', DPath.relativeTo(DPath).toString());
+ Expect.equals('.', NoPath.relativeTo(NoPath).toString());
+ Expect.equals('.', C2Path.relativeTo(cPath).toString());
+ Expect.equals('..', C3Path.relativeTo(cPath).toString());
+ Expect.equals('d', cPath.relativeTo(C3Path).toString());
+ Expect.equals('a/b/d', cPath.relativeTo(C4Path).toString());
+ Expect.equals('../../../', C4Path.relativeTo(cPath).toString());
+}
« no previous file with comments | « sdk/lib/io/path_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698