diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 15:02:57 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 15:02:57 +0000 |
commit | 22e1168491f768ae6ff20ded07b3063ac5fe34db (patch) | |
tree | 7732ac3a44392857058c171dcad6447f4f794026 /base/string_util_unittest.cc | |
parent | abbb497022444fb93c5832ecca5a2c10d610359b (diff) | |
download | chromium_src-22e1168491f768ae6ff20ded07b3063ac5fe34db.zip chromium_src-22e1168491f768ae6ff20ded07b3063ac5fe34db.tar.gz chromium_src-22e1168491f768ae6ff20ded07b3063ac5fe34db.tar.bz2 |
Add test to check that IsStringUTF8 allows for embedded NULLs.
BUG=53507
TEST=new test for an embedded NULL.
Review URL: http://codereview.chromium.org/3124049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r-- | base/string_util_unittest.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 8a8fc39..7bdacea 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -414,6 +414,15 @@ TEST(StringUtilTest, IsStringUTF8) { EXPECT_FALSE(IsStringUTF8("\xd9\xee\xe4\xee")); // U+03B3 U+03B5 U+03B9 U+03AC in ISO-8859-7 EXPECT_FALSE(IsStringUTF8("\xe3\xe5\xe9\xdC")); + + // Check that we support Embedded Nulls. The first uses the canonical UTF-8 + // representation, and the second uses a 2-byte sequence. The second version + // is invalid UTF-8 since UTF-8 states that the shortest encoding for a + // given codepoint must be used. + static const char kEmbeddedNull[] = "embedded\0null"; + EXPECT_TRUE(IsStringUTF8( + std::string(kEmbeddedNull, sizeof(kEmbeddedNull)))); + EXPECT_FALSE(IsStringUTF8("embedded\xc0\x80U+0000")); } TEST(StringUtilTest, ConvertASCII) { |