| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "chrome/browser/net/quoted_printable.h" | 6 #include "chrome/browser/net/quoted_printable.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 TEST(QuotedPrintableTest, Decode) { | 178 TEST(QuotedPrintableTest, Decode) { |
| 179 ASSERT_EQ(arraysize(kNormalText), arraysize(kEncodedText)); | 179 ASSERT_EQ(arraysize(kNormalText), arraysize(kEncodedText)); |
| 180 for (size_t i = 0; i < arraysize(kNormalText); ++i) { | 180 for (size_t i = 0; i < arraysize(kNormalText); ++i) { |
| 181 std::string output; | 181 std::string output; |
| 182 EXPECT_TRUE(chrome::browser::net::QuotedPrintableDecode( | 182 EXPECT_TRUE(chrome::browser::net::QuotedPrintableDecode( |
| 183 kEncodedText[i], &output)); | 183 kEncodedText[i], &output)); |
| 184 std::string expected(kNormalText[i]); | 184 std::string expected(kNormalText[i]); |
| 185 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << | 185 SCOPED_TRACE(::testing::Message() << "Iteration " << i << |
| 186 "\n Actual=\n" << output << "\n Expected=\n" << | 186 "\n Actual=\n" << output << "\n Expected=\n" << |
| 187 expected); | 187 expected); |
| 188 // We cannot test for equality as EOLs won't match the normal text | 188 // We cannot test for equality as EOLs won't match the normal text |
| 189 // (as any EOL is converted to a CRLF during encoding). | 189 // (as any EOL is converted to a CRLF during encoding). |
| 190 EXPECT_TRUE(CompareEOLInsensitive(expected, output)); | 190 EXPECT_TRUE(CompareEOLInsensitive(expected, output)); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Tests that we return false but still do our best to decode badly encoded | 194 // Tests that we return false but still do our best to decode badly encoded |
| 195 // inputs. | 195 // inputs. |
| 196 TEST(QuotedPrintableTest, DecodeBadInput) { | 196 TEST(QuotedPrintableTest, DecodeBadInput) { |
| 197 ASSERT_EQ(arraysize(kBadEncodedText), arraysize(kBadEncodedTextDecoded)); | 197 ASSERT_EQ(arraysize(kBadEncodedText), arraysize(kBadEncodedTextDecoded)); |
| 198 for (size_t i = 0; i < arraysize(kBadEncodedText); ++i) { | 198 for (size_t i = 0; i < arraysize(kBadEncodedText); ++i) { |
| 199 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i); | 199 SCOPED_TRACE(::testing::Message() << "Iteration " << i); |
| 200 std::string output; | 200 std::string output; |
| 201 EXPECT_FALSE(chrome::browser::net::QuotedPrintableDecode( | 201 EXPECT_FALSE(chrome::browser::net::QuotedPrintableDecode( |
| 202 kBadEncodedText[i], &output)); | 202 kBadEncodedText[i], &output)); |
| 203 std::string expected(kBadEncodedTextDecoded[i]); | 203 std::string expected(kBadEncodedTextDecoded[i]); |
| 204 EXPECT_EQ(expected, output); | 204 EXPECT_EQ(expected, output); |
| 205 } | 205 } |
| 206 } | 206 } |
| OLD | NEW |