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

Side by Side Diff: runtime/vm/uri_test.cc

Issue 2037823003: Make ResolveUri return the correct target_uri for relative base uris. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/uri.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/uri.h" 5 #include "vm/uri.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 7
8 namespace dart { 8 namespace dart {
9 9
10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) { 10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 target_uri); 555 target_uri);
556 } 556 }
557 557
558 558
559 // dart:core Uri allows for the base url to be relative (no scheme, no 559 // dart:core Uri allows for the base url to be relative (no scheme, no
560 // authory, relative path) but this behavior is not in RFC 3986. We 560 // authory, relative path) but this behavior is not in RFC 3986. We
561 // do not implement this. 561 // do not implement this.
562 TEST_CASE(ResolveUri_RelativeBase_NotImplemented) { 562 TEST_CASE(ResolveUri_RelativeBase_NotImplemented) {
563 const char* target_uri; 563 const char* target_uri;
564 EXPECT(!ResolveUri("../r1", "b1/b2", &target_uri)); 564 EXPECT(!ResolveUri("../r1", "b1/b2", &target_uri));
565 EXPECT_STREQ("", target_uri); 565 EXPECT(target_uri == NULL);
566 566
567 EXPECT(!ResolveUri("..", "b1/b2", &target_uri)); 567 EXPECT(!ResolveUri("..", "b1/b2", &target_uri));
568 EXPECT_STREQ("", target_uri); 568 EXPECT(target_uri == NULL);
569 569
570 EXPECT(!ResolveUri("../..", "b1/b2", &target_uri)); 570 EXPECT(!ResolveUri("../..", "b1/b2", &target_uri));
571 EXPECT_STREQ("", target_uri); 571 EXPECT(target_uri == NULL);
572 572
573 EXPECT(!ResolveUri("../../..", "b1/b2", &target_uri)); 573 EXPECT(!ResolveUri("../../..", "b1/b2", &target_uri));
574 EXPECT_STREQ("", target_uri); 574 EXPECT(target_uri == NULL);
575 575
576 EXPECT(!ResolveUri("../../../r1", "b1/b2", &target_uri)); 576 EXPECT(!ResolveUri("../../../r1", "b1/b2", &target_uri));
577 EXPECT_STREQ("", target_uri); 577 EXPECT(target_uri == NULL);
578 578
579 EXPECT(!ResolveUri("../r1", "../../b1/b2/b3", &target_uri)); 579 EXPECT(!ResolveUri("../r1", "../../b1/b2/b3", &target_uri));
580 EXPECT_STREQ("", target_uri); 580 EXPECT(target_uri == NULL);
581 581
582 EXPECT(!ResolveUri("../../../r1", "../../b1/b2/b3", &target_uri)); 582 EXPECT(!ResolveUri("../../../r1", "../../b1/b2/b3", &target_uri));
583 EXPECT_STREQ("", target_uri); 583 EXPECT(target_uri == NULL);
584 } 584 }
585 585
586 586
587 static const char* TestResolve(const char* base_uri, const char* uri) { 587 static const char* TestResolve(const char* base_uri, const char* uri) {
588 const char* target_uri; 588 const char* target_uri;
589 EXPECT(ResolveUri(uri, base_uri, &target_uri)); 589 EXPECT(ResolveUri(uri, base_uri, &target_uri));
590 return target_uri; 590 return target_uri;
591 } 591 }
592 592
593 593
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); 672 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e"));
673 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); 673 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e"));
674 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e")); 674 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e"));
675 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/.")); 675 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/."));
676 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./.")); 676 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./."));
677 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././.")); 677 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././."));
678 #undef LH 678 #undef LH
679 } 679 }
680 680
681 } // namespace dart 681 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/uri.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698