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

Unified Diff: third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp

Issue 2704153002: ParsedContentType refactoring (Closed)
Patch Set: fix Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/network/ParsedContentType.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp
diff --git a/third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp b/third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp
index 64ed0d18e5c1b125cfdbd2435def0b4b10279801..aa477fa1e3eae1fb85e4ab7eea932e9da886f165 100644
--- a/third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp
+++ b/third_party/WebKit/Source/platform/network/ParsedContentTypeTest.cpp
@@ -8,9 +8,16 @@
namespace blink {
+namespace {
+
+bool isValid(const String& input) {
+ return ParsedContentType(input).isValid();
+}
+
TEST(ParsedContentTypeTest, MimeTypeWithoutCharset) {
ParsedContentType t("text/plain");
+ EXPECT_TRUE(t.isValid());
EXPECT_EQ("text/plain", t.mimeType());
EXPECT_EQ(String(), t.charset());
}
@@ -18,6 +25,7 @@ TEST(ParsedContentTypeTest, MimeTypeWithoutCharset) {
TEST(ParsedContentTypeTest, MimeTypeWithCharSet) {
ParsedContentType t(" text/plain ; x=y;charset=utf-8 ");
+ EXPECT_TRUE(t.isValid());
EXPECT_EQ("text/plain", t.mimeType());
EXPECT_EQ("utf-8", t.charset());
}
@@ -25,6 +33,7 @@ TEST(ParsedContentTypeTest, MimeTypeWithCharSet) {
TEST(ParsedContentTypeTest, MimeTypeWithQuotedCharSet) {
ParsedContentType t("text/plain; \"charset\"=\"x=y;y=z; ;;\"");
+ EXPECT_TRUE(t.isValid());
EXPECT_EQ("text/plain", t.mimeType());
EXPECT_EQ("x=y;y=z; ;;", t.charset());
}
@@ -35,6 +44,7 @@ TEST(ParsedContentTypeTest, MimeTypeWithQuotedCharSet) {
TEST(ParsedContentTypeTest, InvalidMimeTypeWithoutCharset) {
ParsedContentType t(" ");
+ EXPECT_FALSE(t.isValid());
EXPECT_EQ(String(), t.mimeType());
EXPECT_EQ(String(), t.charset());
}
@@ -42,29 +52,30 @@ TEST(ParsedContentTypeTest, InvalidMimeTypeWithoutCharset) {
TEST(ParsedContentTypeTest, InvalidMimeTypeWithCharset) {
ParsedContentType t("text/plain; charset;");
+ EXPECT_FALSE(t.isValid());
EXPECT_EQ("text/plain", t.mimeType());
EXPECT_EQ(String(), t.charset());
}
TEST(ParsedContentTypeTest, Validity) {
- EXPECT_TRUE(isValidContentType("text/plain"));
- EXPECT_TRUE(isValidContentType("text/plain; charset=utf-8"));
- EXPECT_TRUE(isValidContentType(" text/plain "));
- EXPECT_TRUE(isValidContentType(" text/plain;charset=utf-8 "));
- EXPECT_TRUE(isValidContentType("unknown/unknown"));
- EXPECT_TRUE(isValidContentType("unknown/unknown; charset=unknown"));
- EXPECT_TRUE(isValidContentType("x/y;\"z=\\\"q;t\"=\"ttx&r=z;;kd==\""));
-
- EXPECT_FALSE(isValidContentType("text/plain\r"));
- EXPECT_FALSE(isValidContentType("text/plain\n"));
- EXPECT_FALSE(isValidContentType(""));
- EXPECT_FALSE(isValidContentType(" "));
- EXPECT_FALSE(isValidContentType("text/plain;"));
- EXPECT_FALSE(isValidContentType("text/plain; "));
- EXPECT_FALSE(isValidContentType("text/plain; charset"));
- EXPECT_FALSE(isValidContentType("text/plain; charset;"));
- EXPECT_FALSE(isValidContentType("x/y;\"xx"));
- EXPECT_FALSE(isValidContentType("x/y;\"xx=y"));
+ EXPECT_TRUE(isValid("text/plain"));
+ EXPECT_TRUE(isValid("text/plain; charset=utf-8"));
+ EXPECT_TRUE(isValid(" text/plain "));
+ EXPECT_TRUE(isValid(" text/plain;charset=utf-8 "));
+ EXPECT_TRUE(isValid("unknown/unknown"));
+ EXPECT_TRUE(isValid("unknown/unknown; charset=unknown"));
+ EXPECT_TRUE(isValid("x/y;\"z=\\\"q;t\"=\"ttx&r=z;;kd==\""));
+
+ EXPECT_FALSE(isValid("text/plain\r"));
+ EXPECT_FALSE(isValid("text/plain\n"));
+ EXPECT_FALSE(isValid(""));
+ EXPECT_FALSE(isValid(" "));
+ EXPECT_FALSE(isValid("text/plain;"));
+ EXPECT_FALSE(isValid("text/plain; "));
+ EXPECT_FALSE(isValid("text/plain; charset"));
+ EXPECT_FALSE(isValid("text/plain; charset;"));
+ EXPECT_FALSE(isValid("x/y;\"xx"));
+ EXPECT_FALSE(isValid("x/y;\"xx=y"));
// TODO(yhirano): Add tests for non-tokens. They are currently accepted.
}
@@ -90,4 +101,6 @@ TEST(ParsedContentTypeTest, ParameterName) {
// TODO(yhirano): Trailing spaces of a parameter value should be ignored.
}
+} // namespace
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/network/ParsedContentType.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698