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

Side by Side Diff: src/url_canon_unittest.cc

Issue 600087: When resolving URL, empty relative URL should remove ref component.... (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Changed to use Append. Created 10 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/url_canon_relative.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 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 bool is_base_file; // Tells us if the base is a file URL. 1729 bool is_base_file; // Tells us if the base is a file URL.
1730 const char* test; // Input URL to test against. 1730 const char* test; // Input URL to test against.
1731 bool succeed_relative; // Whether we expect IsRelativeURL to succeed 1731 bool succeed_relative; // Whether we expect IsRelativeURL to succeed
1732 bool is_rel; // Whether we expect |test| to be relative or not. 1732 bool is_rel; // Whether we expect |test| to be relative or not.
1733 bool succeed_resolve; // Whether we expect ResolveRelativeURL to succeed. 1733 bool succeed_resolve; // Whether we expect ResolveRelativeURL to succeed.
1734 const char* resolved; // What we expect in the result when resolving. 1734 const char* resolved; // What we expect in the result when resolving.
1735 } rel_cases[] = { 1735 } rel_cases[] = {
1736 // Basic absolute input. 1736 // Basic absolute input.
1737 {"http://host/a", true, false, "http://another/", true, false, false, NULL}, 1737 {"http://host/a", true, false, "http://another/", true, false, false, NULL},
1738 {"http://host/a", true, false, "http:////another/", true, false, false, NULL }, 1738 {"http://host/a", true, false, "http:////another/", true, false, false, NULL },
1739 // Empty relative URLs shouldn't change the input. 1739 // Empty relative URLs should only remove the ref part of the URL,
1740 // leaving the rest unchanged.
1740 {"http://foo/bar", true, false, "", true, true, true, "http://foo/bar"}, 1741 {"http://foo/bar", true, false, "", true, true, true, "http://foo/bar"},
1742 {"http://foo/bar#ref", true, false, "", true, true, true, "http://foo/bar"},
1743 {"http://foo/bar#", true, false, "", true, true, true, "http://foo/bar"},
1741 // Spaces at the ends of the relative path should be ignored. 1744 // Spaces at the ends of the relative path should be ignored.
1742 {"http://foo/bar", true, false, " another ", true, true, true, "http://foo /another"}, 1745 {"http://foo/bar", true, false, " another ", true, true, true, "http://foo /another"},
1743 {"http://foo/bar", true, false, " . ", true, true, true, "http://foo/"}, 1746 {"http://foo/bar", true, false, " . ", true, true, true, "http://foo/"},
1744 {"http://foo/bar", true, false, " \t ", true, true, true, "http://foo/bar"}, 1747 {"http://foo/bar", true, false, " \t ", true, true, true, "http://foo/bar"},
1745 // Matching schemes without two slashes are treated as relative. 1748 // Matching schemes without two slashes are treated as relative.
1746 {"http://host/a", true, false, "http:path", true, true, true, "http://host/p ath"}, 1749 {"http://host/a", true, false, "http:path", true, true, true, "http://host/p ath"},
1747 {"http://host/a/", true, false, "http:path", true, true, true, "http://host/ a/path"}, 1750 {"http://host/a/", true, false, "http:path", true, true, true, "http://host/ a/path"},
1748 {"http://host/a", true, false, "http:/path", true, true, true, "http://host/ path"}, 1751 {"http://host/a", true, false, "http:/path", true, true, true, "http://host/ path"},
1749 {"http://host/a", true, false, "HTTP:/path", true, true, true, "http://host/ path"}, 1752 {"http://host/a", true, false, "HTTP:/path", true, true, true, "http://host/ path"},
1750 // Nonmatching schemes are absolute. 1753 // Nonmatching schemes are absolute.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 url_canon::StdStringCanonOutput repl_output(&repl_str); 1930 url_canon::StdStringCanonOutput repl_output(&repl_str);
1928 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ; 1931 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ;
1929 repl_output.Complete(); 1932 repl_output.Complete();
1930 1933
1931 // Generate the expected string and check. 1934 // Generate the expected string and check.
1932 std::string expected("file:///foo?"); 1935 std::string expected("file:///foo?");
1933 for (size_t i = 0; i < new_query.length(); i++) 1936 for (size_t i = 0; i < new_query.length(); i++)
1934 expected.push_back('a'); 1937 expected.push_back('a');
1935 EXPECT_TRUE(expected == repl_str); 1938 EXPECT_TRUE(expected == repl_str);
1936 } 1939 }
OLDNEW
« no previous file with comments | « src/url_canon_relative.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698