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

Unified Diff: tests/corelib/uri_file_test.dart

Issue 1089183004: Add Uri.directory constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 5 years, 8 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/directory_impl.dart ('k') | tests/standalone/io/file_system_uri_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_file_test.dart
diff --git a/tests/corelib/uri_file_test.dart b/tests/corelib/uri_file_test.dart
index 194fd9db521b1df7cca207818fd9403cdf51a802..b49b3d5433d7ca02338112040d87de9453182d61 100644
--- a/tests/corelib/uri_file_test.dart
+++ b/tests/corelib/uri_file_test.dart
@@ -91,10 +91,15 @@ testFileUriWindowsSlash() {
];
for (var test in tests) {
- Uri uri;
- uri = new Uri.file(test[1], windows: true);
+ Uri uri = new Uri.file(test[1], windows: true);
Expect.equals(test[0], uri.toString());
Expect.equals(test[2], uri.toFilePath(windows: true));
+ bool couldBeDir = uri.path.isEmpty || uri.path.endsWith('\\');
+ Uri dirUri = new Uri.directory(test[1], windows: true);
+ Expect.isTrue(dirUri.path.isEmpty || dirUri.path.endsWith('/'));
+ if (couldBeDir) {
+ Expect.equals(uri, dirUri);
+ }
}
}
@@ -119,6 +124,12 @@ testFileUriWindowsWin32Namespace() {
Expect.throws(
() => new Uri.file("\\\\?\\UNX\\server\\share\\file", windows: true),
(e) => e is ArgumentError);
+ Expect.throws(
+ () => new Uri.directory("\\\\?\\file", windows: true),
+ (e) => e is ArgumentError);
+ Expect.throws(
+ () => new Uri.directory("\\\\?\\UNX\\server\\share\\file", windows: true),
+ (e) => e is ArgumentError);
}
testFileUriDriveLetter() {
@@ -145,6 +156,12 @@ testFileUriDriveLetter() {
(e) => e is ArgumentError);
Expect.throws(() => new Uri.file("C:a\b", windows: true),
(e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory("C:", windows: true),
+ (e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory("C:a", windows: true),
+ (e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory("C:a\b", windows: true),
+ (e) => e is ArgumentError);
}
testFileUriResolve() {
@@ -197,19 +214,31 @@ testFileUriIllegalCharacters() {
(e) => e is ArgumentError);
Expect.throws(() => new Uri.file("\\$test", windows: true),
(e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory(test, windows: true),
+ (e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory("\\$test", windows: true),
+ (e) => e is ArgumentError);
// It is possible to create non-Windows URIs, but not Windows URIs.
Uri uri = new Uri.file(test, windows: false);
Uri absoluteUri = new Uri.file("/$test", windows: false);
+ Uri dirUri = new Uri.directory(test, windows: false);
+ Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false);
Expect.throws(() => new Uri.file(test, windows: true));
Expect.throws(() => new Uri.file("\\$test", windows: true));
+ Expect.throws(() => new Uri.direcory(test, windows: true));
+ Expect.throws(() => new Uri.directory("\\$test", windows: true));
// It is possible to extract non-Windows file path, but not
// Windows file path.
Expect.equals(test, uri.toFilePath(windows: false));
Expect.equals("/$test", absoluteUri.toFilePath(windows: false));
+ Expect.equals("$test/", dirUri.toFilePath(windows: false));
+ Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false));
Expect.throws(() => uri.toFilePath(windows: true));
Expect.throws(() => absoluteUri.toFilePath(windows: true));
+ Expect.throws(() => dirUri.toFilePath(windows: true));
+ Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true));
}
// Backslash
@@ -218,6 +247,8 @@ testFileUriIllegalCharacters() {
// It is possible to create both non-Windows URIs, and Windows URIs.
Uri uri = new Uri.file(test, windows: false);
Uri absoluteUri = new Uri.file("/$test", windows: false);
+ Uri dirUri = new Uri.directory(test, windows: false);
+ Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false);
new Uri.file(test, windows: true);
new Uri.file("\\$test", windows: true);
@@ -226,19 +257,30 @@ testFileUriIllegalCharacters() {
// in a path segment).
Expect.equals(test, uri.toFilePath(windows: false));
Expect.equals("/$test", absoluteUri.toFilePath(windows: false));
+ Expect.equals("$test/", dirUri.toFilePath(windows: false));
+ Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false));
Expect.throws(() => uri.toFilePath(windows: true),
(e) => e is UnsupportedError);
Expect.throws(() => absoluteUri.toFilePath(windows: true));
+ Expect.throws(() => dirUri.toFilePath(windows: true),
+ (e) => e is UnsupportedError);
+ Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true));
}
}
testFileUriIllegalDriveLetter() {
Expect.throws(() => new Uri.file("1:\\", windows: true),
(e) => e is ArgumentError);
+ Expect.throws(() => new Uri.directory("1:\\", windows: true),
+ (e) => e is ArgumentError);
Uri uri = new Uri.file("1:\\", windows: false);
+ Uri dirUri = new Uri.directory("1:\\", windows: false);
Expect.equals("1:\\", uri.toFilePath(windows: false));
+ Expect.equals("1:\\/", dirUri.toFilePath(windows: false));
Expect.throws(() => uri.toFilePath(windows: true),
(e) => e is UnsupportedError);
+ Expect.throws(() => dirUri.toFilePath(windows: true),
+ (e) => e is UnsupportedError);
}
testAdditionalComponents() {
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | tests/standalone/io/file_system_uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698