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

Unified Diff: tests/corelib/uri_path_test.dart

Issue 16470004: Add leading slash to URI path when required. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 6 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/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_path_test.dart
diff --git a/tests/corelib/uri_path_test.dart b/tests/corelib/uri_path_test.dart
index e997ce36cd759a67760f9eeb34b916b0fd28d0a1..058d91237add29398173a1517aff3ddc74a1aad7 100644
--- a/tests/corelib/uri_path_test.dart
+++ b/tests/corelib/uri_path_test.dart
@@ -8,18 +8,35 @@ void testInvalidArguments() {
}
void testPath() {
- test(s, uri) {
+ void test(s, uri) {
Expect.equals(s, uri.toString());
Expect.equals(uri, Uri.parse(s));
}
+ test("http:", new Uri(scheme: "http"));
+ test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "xxx"));
+ test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "/xxx"));
+ test("http://host/xxx",
+ new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]));
+ test("http://host/xxx/yyy",
+ new Uri(scheme: "http", host: "host", path: "xxx/yyy"));
+ test("http://host/xxx/yyy",
+ new Uri(scheme: "http", host: "host", path: "/xxx/yyy"));
+ test("http://host/xxx/yyy",
+ new Uri(scheme: "http", host: "host", pathSegments: ["xxx", "yyy"]));
+
test("urn:", new Uri(scheme: "urn"));
test("urn:xxx", new Uri(scheme: "urn", path: "xxx"));
test("urn:xxx:yyy", new Uri(scheme: "urn", path: "xxx:yyy"));
+
+ Expect.equals(3, new Uri(path: "xxx/yyy/zzz").pathSegments.length);
+ Expect.equals(3, new Uri(path: "/xxx/yyy/zzz").pathSegments.length);
+ Expect.equals(3, Uri.parse("http://host/xxx/yyy/zzz").pathSegments.length);
+ Expect.equals(3, Uri.parse("file:///xxx/yyy/zzz").pathSegments.length);
}
void testPathSegments() {
- test(String path, List<String> segments) {
+ void test(String path, List<String> segments) {
void check(uri) {
Expect.equals(path, uri.path);
Expect.equals(path, uri.toString());
@@ -72,11 +89,41 @@ void testPathSegments() {
unencoded = unencoded.toString();
test(encoded, [unencoded]);
test(encoded + "/" + encoded, [unencoded, unencoded]);
+
+ Uri uri;
+ uri = new Uri(pathSegments: ["xxx", "yyy", "zzz"]);
+ Expect.equals(3, uri.pathSegments.length);
+ uri = new Uri(scheme: "http",
+ host: "host",
+ pathSegments: ["xxx", "yyy", "zzz"]);
+ Expect.equals(3, uri.pathSegments.length);
+ uri = new Uri(scheme: "file",
+ pathSegments: ["xxx", "yyy", "zzz"]);
+ Expect.equals(3, uri.pathSegments.length);
}
-testPathSegmentsUnmodifiableList() {
+void testPathCompare() {
+ void test(Uri uri1, Uri uri2) {
+ Expect.equals(uri1, uri2);
+ Expect.equals(uri2, uri1);
+ }
+
+ test(new Uri(scheme: "http", host: "host", path: "xxx"),
+ new Uri(scheme: "http", host: "host", path: "/xxx"));
+ test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]),
+ new Uri(scheme: "http", host: "host", path: "/xxx"));
+ test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]),
+ new Uri(scheme: "http", host: "host", path: "xxx"));
+ test(new Uri(scheme: "file", path: "xxx"),
+ new Uri(scheme: "file", path: "/xxx"));
+ test(new Uri(scheme: "file", pathSegments: ["xxx"]),
+ new Uri(scheme: "file", path: "/xxx"));
+ test(new Uri(scheme: "file", pathSegments: ["xxx"]),
+ new Uri(scheme: "file", path: "xxx"));
+}
- test(list) {
+testPathSegmentsUnmodifiableList() {
+ void test(list) {
bool isUnsupported(e) => e is UnsupportedError;
Expect.equals("a", list[0]);
@@ -118,5 +165,6 @@ main() {
testInvalidArguments();
testPath();
testPathSegments();
+ testPathCompare();
testPathSegmentsUnmodifiableList();
}
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698