diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 12:34:51 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 12:34:51 +0000 |
commit | 1e3f8396c6f205b2be2a102d4fbca870638e7f6b (patch) | |
tree | 1469fef44e3ecc99921a2bbe1b67518215532de9 /base/string_escape_unittest.cc | |
parent | 5d99d63b5d185d490531517570e0b0a27ca9dfa0 (diff) | |
download | chromium_src-1e3f8396c6f205b2be2a102d4fbca870638e7f6b.zip chromium_src-1e3f8396c6f205b2be2a102d4fbca870638e7f6b.tar.gz chromium_src-1e3f8396c6f205b2be2a102d4fbca870638e7f6b.tar.bz2 |
Add a few tests to string_escape improving code coverage.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_escape_unittest.cc')
-rw-r--r-- | base/string_escape_unittest.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/base/string_escape_unittest.cc b/base/string_escape_unittest.cc index dda0d2a7..502f122 100644 --- a/base/string_escape_unittest.cc +++ b/base/string_escape_unittest.cc @@ -33,6 +33,7 @@ TEST(StringEscapeTest, JavascriptDoubleQuote) { static const char* kToEscape = "\b\001aZ\"\\wee"; static const char* kEscaped = "\\b\\x01aZ\\\"\\\\wee"; + static const char* kEscapedQuoted = "\"\\b\\x01aZ\\\"\\\\wee\""; static const wchar_t* kUToEscape = L"\b\x0001" L"a\x123fZ\"\\wee"; static const char* kUEscaped = "\\b\\x01a\\u123FZ\\\"\\\\wee"; static const char* kUEscapedQuoted = "\"\\b\\x01a\\u123FZ\\\"\\\\wee\""; @@ -63,6 +64,10 @@ TEST(StringEscapeTest, JavascriptDoubleQuote) { string_escape::JavascriptDoubleQuote(std::string(kToEscape), false, &out); ASSERT_EQ(std::string("testy: ") + kEscaped, out); + out = "testy: "; + string_escape::JavascriptDoubleQuote(std::string(kToEscape), true, &out); + ASSERT_EQ(std::string("testy: ") + kEscapedQuoted, out); + // Test null, non-printable, and non-7bit std::string str("TeSt"); str.push_back(0); @@ -75,4 +80,9 @@ TEST(StringEscapeTest, JavascriptDoubleQuote) { out = "testy: "; string_escape::JavascriptDoubleQuote(str, false, &out); ASSERT_EQ("testy: TeSt\\x00\\x0F\\x7F\xf0\x80!", out); + + // Test escape sequences + out = "testy: "; + string_escape::JavascriptDoubleQuote("a\b\f\n\r\t\v\1\\.\"z", false, &out); + ASSERT_EQ("testy: a\\b\\f\\n\\r\\t\\v\\x01\\\\.\\\"z", out); } |