| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |