Chromium Code Reviews

Side by Side Diff: src/url_canon_unittest.cc

Issue 9956109: Fix URLCanonTest.CanonicalizeFileSystemURL (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 1660 matching lines...)
1671 EXPECT_EQ(4, out_parsed.scheme.len); 1671 EXPECT_EQ(4, out_parsed.scheme.len);
1672 1672
1673 EXPECT_EQ(cases[i].expected_host.begin, out_parsed.host.begin); 1673 EXPECT_EQ(cases[i].expected_host.begin, out_parsed.host.begin);
1674 EXPECT_EQ(cases[i].expected_host.len, out_parsed.host.len); 1674 EXPECT_EQ(cases[i].expected_host.len, out_parsed.host.len);
1675 1675
1676 EXPECT_EQ(cases[i].expected_path.begin, out_parsed.path.begin); 1676 EXPECT_EQ(cases[i].expected_path.begin, out_parsed.path.begin);
1677 EXPECT_EQ(cases[i].expected_path.len, out_parsed.path.len); 1677 EXPECT_EQ(cases[i].expected_path.len, out_parsed.path.len);
1678 } 1678 }
1679 } 1679 }
1680 1680
1681 /*
1682 TODO(ericu) bug 121671 this test fails.
1683 #ifdef FULL_FILESYSTEM_URL_SUPPORT 1681 #ifdef FULL_FILESYSTEM_URL_SUPPORT
1684 TEST(URLCanonTest, CanonicalizeFileSystemURL) { 1682 TEST(URLCanonTest, CanonicalizeFileSystemURL) {
1685 struct URLCase { 1683 struct URLCase {
1686 const char* input; 1684 const char* input;
1687 const char* expected; 1685 const char* expected;
1688 bool expected_success; 1686 bool expected_success;
1689 } cases[] = { 1687 } cases[] = {
1690 {"Filesystem:htTp://www.Foo.com:80/tempoRary", "filesystem:http://www.foo.co m/tempoRary/", true}, 1688 {"Filesystem:htTp://www.Foo.com:80/tempoRary", "filesystem:http://www.foo.co m/tempoRary/", true},
1691 {"filesystem:httpS://www.foo.com/temporary/", "filesystem:https://www.foo.co m/temporary/", true}, 1689 {"filesystem:httpS://www.foo.com/temporary/", "filesystem:https://www.foo.co m/temporary/", true},
1692 {"filesystem:http://www.foo.com//", "filesystem:http://www.foo.com//", false }, 1690 {"filesystem:http://www.foo.com//", "filesystem:http://www.foo.com//", false },
1693 {"filesystem:http://www.foo.com/persistent/bob?query#ref", "filesystem:http: //www.foo.com/persistent/bob?query#ref", true}, 1691 {"filesystem:http://www.foo.com/persistent/bob?query#ref", "filesystem:http: //www.foo.com/persistent/bob?query#ref", true},
1694 {"filesystem:fIle://\\temporary/", "filesystem:file:///temporary/", true}, 1692 {"filesystem:fIle://\\temporary/", "filesystem:file:///temporary/", true},
1695 {"filesystem:fiLe:///temporary", "filesystem:file:///temporary/", true}, 1693 {"filesystem:fiLe:///temporary", "filesystem:file:///temporary/", true},
1696 {"filesystem:file://///temporary", "filesystem:file:///temporary/", true}, 1694 {"filesystem:file:///////temporary", "filesystem:file:////", false},
1697 {"filesystem:File:///temporary/Bob?qUery#reF", "filesystem:file:///temporary /Bob?qUery#reF", true}, 1695 {"filesystem:File:///temporary/Bob?qUery#reF", "filesystem:file:///temporary /Bob?qUery#reF", true},
1698 }; 1696 };
1699 1697
1700 for (size_t i = 0; i < ARRAYSIZE(cases); i++) { 1698 for (size_t i = 0; i < ARRAYSIZE(cases); i++) {
1701 int url_len = static_cast<int>(strlen(cases[i].input)); 1699 int url_len = static_cast<int>(strlen(cases[i].input));
1702 url_parse::Parsed parsed; 1700 url_parse::Parsed parsed;
1703 url_parse::ParseFileSystemURL(cases[i].input, url_len, &parsed); 1701 url_parse::ParseFileSystemURL(cases[i].input, url_len, &parsed);
1704 1702
1705 url_parse::Parsed out_parsed; 1703 url_parse::Parsed out_parsed;
1706 std::string out_str; 1704 std::string out_str;
1707 url_canon::StdStringCanonOutput output(&out_str); 1705 url_canon::StdStringCanonOutput output(&out_str);
1708 bool success = url_canon::CanonicalizeFileSystemURL(cases[i].input, url_len, 1706 bool success = url_canon::CanonicalizeFileSystemURL(cases[i].input, url_len,
1709 parsed, NULL, &output, 1707 parsed, NULL, &output,
1710 &out_parsed); 1708 &out_parsed);
1711 output.Complete(); 1709 output.Complete();
1712 1710
1713 EXPECT_EQ(cases[i].expected_success, success); 1711 EXPECT_EQ(cases[i].expected_success, success);
1714 EXPECT_EQ(cases[i].expected, out_str); 1712 EXPECT_EQ(cases[i].expected, out_str);
1715 1713
1716 // Make sure the spec was properly identified, the filesystem canonicalizer 1714 // Make sure the spec was properly identified, the filesystem canonicalizer
1717 // has different code for writing the spec. 1715 // has different code for writing the spec.
1718 EXPECT_EQ(0, out_parsed.scheme.begin); 1716 EXPECT_EQ(0, out_parsed.scheme.begin);
1719 EXPECT_EQ(10, out_parsed.scheme.len); 1717 EXPECT_EQ(10, out_parsed.scheme.len);
1720 } 1718 }
1721 } 1719 }
1722 #endif 1720 #endif
1723 */
1724 1721
1725 TEST(URLCanonTest, CanonicalizePathURL) { 1722 TEST(URLCanonTest, CanonicalizePathURL) {
1726 // Path URLs should get canonicalized schemes but nothing else. 1723 // Path URLs should get canonicalized schemes but nothing else.
1727 struct PathCase { 1724 struct PathCase {
1728 const char* input; 1725 const char* input;
1729 const char* expected; 1726 const char* expected;
1730 } path_cases[] = { 1727 } path_cases[] = {
1731 {"javascript:", "javascript:"}, 1728 {"javascript:", "javascript:"},
1732 {"JavaScript:Foo", "javascript:Foo"}, 1729 {"JavaScript:Foo", "javascript:Foo"},
1733 {":\":This /is interesting;?#", ":\":This /is interesting;?#"}, 1730 {":\":This /is interesting;?#", ":\":This /is interesting;?#"},
(...skipping 395 matching lines...)
2129 url_canon::StdStringCanonOutput repl_output(&repl_str); 2126 url_canon::StdStringCanonOutput repl_output(&repl_str);
2130 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ; 2127 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ;
2131 repl_output.Complete(); 2128 repl_output.Complete();
2132 2129
2133 // Generate the expected string and check. 2130 // Generate the expected string and check.
2134 std::string expected("file:///foo?"); 2131 std::string expected("file:///foo?");
2135 for (size_t i = 0; i < new_query.length(); i++) 2132 for (size_t i = 0; i < new_query.length(); i++)
2136 expected.push_back('a'); 2133 expected.push_back('a');
2137 EXPECT_TRUE(expected == repl_str); 2134 EXPECT_TRUE(expected == repl_str);
2138 } 2135 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine