diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 00:15:50 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 00:15:50 +0000 |
commit | 7759c9a7b587662988fa1357c17c273ee64fb3bd (patch) | |
tree | 2017261ac427e79c5b8bcf8ea04dda96c7d79002 /net/base | |
parent | 8e11188942421f584119483ac2987dc3bcef8ac4 (diff) | |
download | chromium_src-7759c9a7b587662988fa1357c17c273ee64fb3bd.zip chromium_src-7759c9a7b587662988fa1357c17c273ee64fb3bd.tar.gz chromium_src-7759c9a7b587662988fa1357c17c273ee64fb3bd.tar.bz2 |
Add more files to the net module compile list. Had to make some small changes to how static struct arrays were declared so arraysize() would work with gcc.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/data_url_unittest.cc | 16 | ||||
-rw-r--r-- | net/base/escape_unittest.cc | 68 |
2 files changed, 46 insertions, 38 deletions
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc index 3eae2d5..719fd83 100644 --- a/net/base/data_url_unittest.cc +++ b/net/base/data_url_unittest.cc @@ -34,19 +34,21 @@ namespace { + struct ParseTestData { + const char* url; + bool is_valid; + const char* mime_type; + const char* charset; + const char* data; + }; + class DataURLTest : public testing::Test { }; } TEST(DataURLTest, Parse) { - const struct { - const char* url; - bool is_valid; - const char* mime_type; - const char* charset; - const char* data; - } tests[] = { + const ParseTestData tests[] = { { "data:", false, "", diff --git a/net/base/escape_unittest.cc b/net/base/escape_unittest.cc index 53100a91..6a201d4 100644 --- a/net/base/escape_unittest.cc +++ b/net/base/escape_unittest.cc @@ -36,22 +36,48 @@ #include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" -struct unescape_case { +namespace { + +struct EscapeCase { + const wchar_t* input; + const wchar_t* output; +}; + +struct UnescapeURLCase { const char* input; + UnescapeRule::Type rules; const char* output; }; +struct UnescapeAndDecodeURLCase { + const char* encoding; + const char* input; + + // The expected output when run through UnescapeURL. + const char* url_unescaped; + + // The expected output when run through UnescapeQuery. + const char* query_unescaped; + + // The expected output when run through UnescapeAndDecodeURLComponent. + const wchar_t* decoded; +}; + +struct EscapeForHTMLCase { + const char* input; + const char* expected_output; +}; + +} + TEST(Escape, EscapeTextForFormSubmission) { - struct escape_case { - const wchar_t* input; - const wchar_t* output; - } escape_cases[] = { + const EscapeCase escape_cases[] = { {L"foo", L"foo"}, {L"foo bar", L"foo+bar"}, {L"foo++", L"foo%2B%2B"} }; for (int i = 0; i < arraysize(escape_cases); ++i) { - escape_case value = escape_cases[i]; + EscapeCase value = escape_cases[i]; EXPECT_EQ(value.output, EscapeQueryParamValueUTF8(value.input)); } @@ -72,9 +98,8 @@ TEST(Escape, EscapeTextForFormSubmission) { EXPECT_EQ(out, std::string("+")); } else if (no_escape.find(in) == std::string::npos) { // Check %hex escaping - char buf[4]; - sprintf_s(buf, 4, "%%%02X", i); - EXPECT_EQ(std::string(buf), out); + std::string expected = StringPrintf("%%%02X", i); + EXPECT_EQ(expected, out); } else { // No change for things in the no_escape list. EXPECT_EQ(out, in); @@ -109,11 +134,7 @@ TEST(Escape, EscapePath) { } TEST(Escape, UnescapeURLComponent) { - struct UnescapeCase { - const char* input; - UnescapeRule::Type rules; - const char* output; - } unescape_cases[] = { + const UnescapeURLCase unescape_cases[] = { {"", UnescapeRule::NORMAL, ""}, {"%2", UnescapeRule::NORMAL, "%2"}, {"%%%%%%", UnescapeRule::NORMAL, "%%%%%%"}, @@ -162,19 +183,7 @@ TEST(Escape, UnescapeURLComponent) { } TEST(Escape, UnescapeAndDecodeURLComponent) { - struct UnescapeCase { - const char* encoding; - const char* input; - - // The expected output when run through UnescapeURL. - const char* url_unescaped; - - // The expected output when run through UnescapeQuery. - const char* query_unescaped; - - // The expected output when run through UnescapeAndDecodeURLComponent. - const wchar_t* decoded; - } unescape_cases[] = { + const UnescapeAndDecodeURLCase unescape_cases[] = { {"UTF8", "+", "+", " ", L"+"}, {"UTF8", "%2+", "%2+", "%2 ", L"%2+"}, {"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"}, @@ -226,10 +235,7 @@ TEST(Escape, UnescapeAndDecodeURLComponent) { } TEST(Escape, EscapeForHTML) { - static const struct { - const char* input; - const char* expected_output; - } tests[] = { + const EscapeForHTMLCase tests[] = { { "hello", "hello" }, { "<hello>", "<hello>" }, { "don\'t mess with me", "don't mess with me" }, |