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

Unified Diff: tests/corelib/uri_test.dart

Issue 2664453003: Add Uri.isScheme test function. (Closed)
Patch Set: Address comment. Created 3 years, 11 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/core/uri.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_test.dart
diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart
index bcd097695f582943aeca0030b927f740d1fd8971..76c59cf3758f915802d4986b9061f8ef6a511a65 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -33,10 +33,21 @@ testUri(String uriText, bool isAbsolute) {
Uri.parse(uriText + "#fragment").removeFragment());
}
- // Test uri.replace on uri with fragment
- uri = Uri.parse('http://hello.com/fake#fragment');
- uri = uri.replace(path: "D/E/E");
- Expect.stringEquals('http://hello.com/D/E/E#fragment', uri.toString());
+ Expect.isTrue(uri.isScheme(uri.scheme));
+ Expect.isTrue(uri.isScheme(uri.scheme.toLowerCase()));
+ Expect.isTrue(uri.isScheme(uri.scheme.toUpperCase()));
+ if (uri.hasScheme) {
+ // Capitalize
+ Expect.isTrue(uri.isScheme(
+ uri.scheme[0].toUpperCase()+uri.scheme.substring(1)));
+ Expect.isFalse(uri.isScheme(
+ uri.scheme.substring(0, uri.scheme.length - 1)));
+ Expect.isFalse(uri.isScheme(uri.scheme + ":"));
+ Expect.isFalse(uri.isScheme(uri.scheme + "\x00"));
+ } else {
+ Expect.isTrue(uri.isScheme(null));
+ Expect.isFalse(uri.isScheme(":"));
+ }
}
testEncodeDecode(String orig, String encoded) {
@@ -753,6 +764,11 @@ void testReplace() {
Expect.equals("s://a:1/b/c?#e", uri.replace(query: "").toString());
Expect.equals("s://a:1?d#e", uri.replace(path: "").toString());
Expect.equals("s://:1/b/c?d#e", uri.replace(host: "").toString());
+
+ // Test uri.replace on uri with fragment
+ uri = Uri.parse('http://hello.com/fake#fragment');
+ uri = uri.replace(path: "D/E/E");
+ Expect.stringEquals('http://hello.com/D/E/E#fragment', uri.toString());
}
void testRegression28359() {
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698