Index: url/url_parse_unittest.cc |
diff --git a/url/url_parse_unittest.cc b/url/url_parse_unittest.cc |
index a65ff858b460149fd5dba2271991c130b78a3a69..7cbccb67e3af01401ac8633716d23b3eed884cbe 100644 |
--- a/url/url_parse_unittest.cc |
+++ b/url/url_parse_unittest.cc |
@@ -459,6 +459,34 @@ TEST(URLParser, ExtractFileName) { |
} |
} |
+TEST(URLParser, ExtractFileExtension) { |
+ struct FileCase { |
+ const char* input; |
+ const char* expected; |
+ } file_cases[] = { |
+ {"http://www.google.com", NULL}, |
+ {"http://www.google.com/", NULL}, |
+ {"http://www.google.com/.foo", NULL}, |
+ {"http://www.google.com/foo.bar", "bar"}, |
+ {"http://www.google.com/foo.", ""}, |
+ {"http://www.google.com/.foo.bar", "bar"}, |
+ {"http://www.google.com/a.b.c", "c"}, |
+ }; |
+ |
+ for (size_t i = 0; i < ARRAYSIZE(file_cases); i++) { |
+ const char* url = file_cases[i].input; |
+ int len = static_cast<int>(strlen(url)); |
+ |
+ url_parse::Parsed parsed; |
+ url_parse::ParseStandardURL(url, len, &parsed); |
+ |
+ url_parse::Component file_name; |
+ url_parse::ExtractFileExtension(url, parsed.path, &file_name); |
+ |
+ EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name)); |
+ } |
+} |
+ |
// Returns true if the parameter with index |parameter| in the given URL's |
// query string. The expected key can be NULL to indicate no such key index |
// should exist. The parameter number is 1-based. |