12#define EXPECT_USTREQ(expected, actual) EXPECT_STREQ(expected, actual.get())
15 auto uri =
ParseUri(
"foo://example.com:8042/over/there");
18 EXPECT(uri->userinfo ==
nullptr);
22 EXPECT(uri->query ==
nullptr);
23 EXPECT(uri->fragment ==
nullptr);
27 auto uri =
ParseUri(
"foo://example.com:8042/over/there?name=ferret");
30 EXPECT(uri->userinfo ==
nullptr);
35 EXPECT(uri->fragment ==
nullptr);
39 auto uri =
ParseUri(
"foo://example.com:8042/over/there#fragment");
42 EXPECT(uri->userinfo ==
nullptr);
46 EXPECT(uri->query ==
nullptr);
50TEST_CASE(ParseUri_WithScheme_WithQueryWithFragment) {
51 auto uri =
ParseUri(
"foo://example.com:8042/over/there?name=ferret#fragment");
54 EXPECT(uri->userinfo ==
nullptr);
63 auto uri =
ParseUri(
"foo://user@example.com:8042/over/there");
70 EXPECT(uri->query ==
nullptr);
71 EXPECT(uri->fragment ==
nullptr);
75 auto uri =
ParseUri(
"foo://example.com:8042/");
78 EXPECT(uri->userinfo ==
nullptr);
82 EXPECT(uri->query ==
nullptr);
83 EXPECT(uri->fragment ==
nullptr);
87 auto uri =
ParseUri(
"foo://example.com:8042");
90 EXPECT(uri->userinfo ==
nullptr);
94 EXPECT(uri->query ==
nullptr);
95 EXPECT(uri->fragment ==
nullptr);
102 EXPECT(uri->userinfo ==
nullptr);
103 EXPECT(uri->host ==
nullptr);
104 EXPECT(uri->port ==
nullptr);
106 EXPECT(uri->query ==
nullptr);
107 EXPECT(uri->fragment ==
nullptr);
114 EXPECT(uri->userinfo ==
nullptr);
115 EXPECT(uri->host ==
nullptr);
116 EXPECT(uri->port ==
nullptr);
118 EXPECT(uri->query ==
nullptr);
119 EXPECT(uri->fragment ==
nullptr);
123 auto uri =
ParseUri(
"//example.com:8042/over/there");
125 EXPECT(uri->scheme ==
nullptr);
126 EXPECT(uri->userinfo ==
nullptr);
130 EXPECT(uri->query ==
nullptr);
131 EXPECT(uri->fragment ==
nullptr);
137 EXPECT(uri->scheme ==
nullptr);
138 EXPECT(uri->userinfo ==
nullptr);
139 EXPECT(uri->host ==
nullptr);
140 EXPECT(uri->port ==
nullptr);
142 EXPECT(uri->query ==
nullptr);
143 EXPECT(uri->fragment ==
nullptr);
148 auto uri =
ParseUri(
"/ov:er/there");
150 EXPECT(uri->scheme ==
nullptr);
151 EXPECT(uri->userinfo ==
nullptr);
152 EXPECT(uri->host ==
nullptr);
153 EXPECT(uri->port ==
nullptr);
155 EXPECT(uri->query ==
nullptr);
161 EXPECT(uri->scheme ==
nullptr);
162 EXPECT(uri->userinfo ==
nullptr);
163 EXPECT(uri->host ==
nullptr);
164 EXPECT(uri->port ==
nullptr);
166 EXPECT(uri->query ==
nullptr);
167 EXPECT(uri->fragment ==
nullptr);
173 EXPECT(uri->scheme ==
nullptr);
174 EXPECT(uri->userinfo ==
nullptr);
175 EXPECT(uri->host ==
nullptr);
176 EXPECT(uri->port ==
nullptr);
178 EXPECT(uri->query ==
nullptr);
179 EXPECT(uri->fragment ==
nullptr);
185 EXPECT(uri->scheme ==
nullptr);
186 EXPECT(uri->userinfo ==
nullptr);
187 EXPECT(uri->host ==
nullptr);
188 EXPECT(uri->port ==
nullptr);
190 EXPECT(uri->query ==
nullptr);
191 EXPECT(uri->fragment ==
nullptr);
195 auto uri =
ParseUri(
"?name=ferret");
197 EXPECT(uri->scheme ==
nullptr);
198 EXPECT(uri->userinfo ==
nullptr);
199 EXPECT(uri->host ==
nullptr);
200 EXPECT(uri->port ==
nullptr);
203 EXPECT(uri->fragment ==
nullptr);
209 EXPECT(uri->scheme ==
nullptr);
210 EXPECT(uri->userinfo ==
nullptr);
211 EXPECT(uri->host ==
nullptr);
212 EXPECT(uri->port ==
nullptr);
214 EXPECT(uri->query ==
nullptr);
222 EXPECT(uri->userinfo ==
nullptr);
223 EXPECT(uri->host ==
nullptr);
224 EXPECT(uri->port ==
nullptr);
226 EXPECT(uri->query ==
nullptr);
227 EXPECT(uri->fragment ==
nullptr);
232 ParseUri(
"scheme:/This%09Is A P%61th?This%09Is A Qu%65ry#A Fr%61gment");
235 EXPECT(uri->userinfo ==
nullptr);
236 EXPECT(uri->host ==
nullptr);
237 EXPECT(uri->port ==
nullptr);
243TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapesPreferred) {
244 auto uri =
ParseUri(
"scheme:/%1b%1B");
247 EXPECT(uri->userinfo ==
nullptr);
248 EXPECT(uri->host ==
nullptr);
249 EXPECT(uri->port ==
nullptr);
251 EXPECT(uri->query ==
nullptr);
252 EXPECT(uri->fragment ==
nullptr);
256 auto uri =
ParseUri(
"scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/");
263 EXPECT(uri->query ==
nullptr);
264 EXPECT(uri->fragment ==
nullptr);
267TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapeInHost) {
268 auto uri =
ParseUri(
"scheme://tEst%1b/");
271 EXPECT(uri->userinfo ==
nullptr);
273 EXPECT(uri->port ==
nullptr);
275 EXPECT(uri->query ==
nullptr);
276 EXPECT(uri->fragment ==
nullptr);
283 EXPECT(uri->userinfo ==
nullptr);
284 EXPECT(uri->host ==
nullptr);
285 EXPECT(uri->port ==
nullptr);
287 EXPECT(uri->query ==
nullptr);
288 EXPECT(uri->fragment ==
nullptr);
292 auto target_uri =
ResolveUri(
"rscheme:/ref/path",
293 "bscheme://buser@bhost:11/base/path?baseQuery");
298TEST_CASE(ResolveUri_WithScheme_WithAuthorityWithQuery) {
299 auto target_uri =
ResolveUri(
"rscheme://ruser@rhost:22/ref/path?refQuery",
300 "bscheme://buser@bhost:11/base/path?baseQuery");
302 EXPECT_USTREQ(
"rscheme://ruser@rhost:22/ref/path?refQuery", target_uri);
306 auto target_uri =
ResolveUri(
"//ruser@rhost:22/ref/path",
307 "bscheme://buser@bhost:11/base/path?baseQuery");
309 EXPECT_USTREQ(
"bscheme://ruser@rhost:22/ref/path", target_uri);
314 ResolveUri(
"/ref/path",
"bscheme://buser@bhost:11/base/path?baseQuery");
316 EXPECT_USTREQ(
"bscheme://buser@bhost:11/ref/path", target_uri);
321 ResolveUri(
"ref/path",
"bscheme://buser@bhost:11/base/path?baseQuery");
323 EXPECT_USTREQ(
"bscheme://buser@bhost:11/base/ref/path", target_uri);
326TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathEmptyBasePath) {
327 auto target_uri =
ResolveUri(
"ref/path",
"bscheme://buser@bhost:11");
329 EXPECT_USTREQ(
"bscheme://buser@bhost:11/ref/path", target_uri);
332TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathWeirdBasePath) {
333 auto target_uri =
ResolveUri(
"ref/path",
"bscheme:base");
340 ResolveUri(
"",
"bscheme://buser@bhost:11/base/path?baseQuery#bfragment");
343 EXPECT_USTREQ(
"bscheme://buser@bhost:11/base/path?baseQuery", target_uri);
346TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithQuery) {
348 "?refQuery",
"bscheme://buser@bhost:11/base/path?baseQuery#bfragment");
350 EXPECT_USTREQ(
"bscheme://buser@bhost:11/base/path?refQuery", target_uri);
353TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithFragment) {
355 "#rfragment",
"bscheme://buser@bhost:11/base/path?baseQuery#bfragment");
357 EXPECT_USTREQ(
"bscheme://buser@bhost:11/base/path?baseQuery#rfragment",
362 auto target_uri =
ResolveUri(
"./refpath",
"scheme://auth/a/b/c/d");
368 auto target_uri =
ResolveUri(
"././refpath",
"scheme://auth/a/b/c/d");
373TEST_CASE(ResolveUri_RemoveDots_RemoveOneDotDotSegment) {
374 auto target_uri =
ResolveUri(
"../refpath",
"scheme://auth/a/b/c/d");
379TEST_CASE(ResolveUri_RemoveDots_RemoveTwoDotDotSegments) {
380 auto target_uri =
ResolveUri(
"../../refpath",
"scheme://auth/a/b/c/d");
385TEST_CASE(ResolveUri_RemoveDots_RemoveTooManyDotDotSegments) {
387 ResolveUri(
"../../../../../../../../../refpath",
"scheme://auth/a/b/c/d");
392TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft1) {
393 auto target_uri =
ResolveUri(
"../../../../..",
"scheme://auth/a/b/c/d");
398TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft2) {
399 auto target_uri =
ResolveUri(
".",
"scheme://auth/");
404TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsInitialPrefix) {
405 auto target_uri =
ResolveUri(
"../../../../refpath",
"scheme://auth");
410TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsMixed) {
411 auto target_uri =
ResolveUri(
"../../1/./2/../3/4/../5/././6/../7",
412 "scheme://auth/a/b/c/d/e");
417TEST_CASE(ResolveUri_NormalizeEscapes_PathQueryFragment) {
419 "#A Fr%61gment",
"scheme:/This%09Is A P%61th?This%09Is A Qu%65ry");
422 "scheme:/This%09Is%20A%20Path?This%09Is%20A%20Query#A%20Fragment",
426TEST_CASE(ResolveUri_NormalizeEscapes_UppercaseHexPreferred) {
427 auto target_uri =
ResolveUri(
"",
"scheme:/%1b%1B");
433 auto target_uri =
ResolveUri(
"",
"scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/");
437 EXPECT_USTREQ(
"scheme://UsEr%20NaMe@host.com:80/", target_uri);
440TEST_CASE(ResolveUri_NormalizeEscapes_BrokenEscapeSequence) {
441 auto target_uri =
ResolveUri(
"",
"scheme:/%1g");
448 const char* data_uri =
450 "dart;charset=utf-8,%20%20%20%20%20%20%20%20import%20%22dart:isolate%22;%"
451 "0A%0A%20%20%20%20%20%20%20%20import%20%22package:stream_channel/"
452 "stream_channel.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%"
453 "22package:test/src/runner/plugin/"
454 "remote_platform_helpers.dart%22;%0A%20%20%20%20%20%20%20%20import%20%"
455 "22package:test/src/runner/vm/"
456 "catch_isolate_errors.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%"
457 "22file:///home/sra/xxxx/dev_compiler/test/"
458 "all_tests.dart%22%20as%20test;%0A%0A%20%20%20%20%20%20%20%20void%20main("
459 "_,%20SendPort%20message)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%"
460 "20channel%20=%20serializeSuite(()%20%7B%0A%20%20%20%20%20%20%20%20%20%"
461 "20%20%20catchIsolateErrors();%0A%20%20%20%20%20%20%20%20%20%20%20%"
462 "20return%20test.main;%0A%20%20%20%20%20%20%20%20%20%20%7D);%0A%20%20%20%"
463 "20%20%20%20%20%20%20new%20IsolateChannel.connectSend(message).pipe("
464 "channel);%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20";
467 data_uri,
"bscheme://buser@bhost:11/base/path?baseQuery#bfragment");
499 const char*
base =
"http://a/b/c/d;p?q";
554 const char*
base =
"/";
567#define LH "http://localhost"
583TEST_CASE(ResolveUri_WindowsPaths_Forwardslash_NoScheme) {
585 "c:/Users/USERNA~1/AppData/Local/Temp/a/b.dll",
586 TestResolve(
"C:/Users/USERNA~1/AppData/Local/Temp/a/out.dill",
"b.dll"));
593TEST_CASE(ResolveUri_WindowsPaths_Forwardslash_FileScheme) {
596 "C:/Users/USERNA~1/AppData/Local/Temp/a/b.dll",
597 TestResolve(
"file:///C:/Users/USERNA~1/AppData/Local/Temp/a/out.dill",
605 "file:///C:\\Users\\USERNA~1\\AppData\\Local\\Temp\\a\\out.dill",
CStringUniquePtr TestResolve(const char *base_uri, const char *uri)
std::unique_ptr< ParsedUri > ParseUri(const char *uri)
CStringUniquePtr ResolveUri(const char *ref_uri, const char *base_uri)
TEST_CASE(DirectoryCurrent)
const myers::Point & get(const myers::Segment &)
#define EXPECT_USTREQ(expected, actual)