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

Side by Side Diff: components/webdata/encryptor/encryptor_unittest.cc

Issue 113403006: Update some uses of char16 to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "components/webdata/encryptor/encryptor.h" 5 #include "components/webdata/encryptor/encryptor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 EXPECT_EQ(plaintext, result); 45 EXPECT_EQ(plaintext, result);
46 46
47 // Test a 16-byte aligned string. This previously hit a boundary error in 47 // Test a 16-byte aligned string. This previously hit a boundary error in
48 // base::Encryptor::Crypt() on Mac. 48 // base::Encryptor::Crypt() on Mac.
49 plaintext = base::ASCIIToUTF16("1234567890123456"); 49 plaintext = base::ASCIIToUTF16("1234567890123456");
50 EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext)); 50 EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
51 EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result)); 51 EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
52 EXPECT_EQ(plaintext, result); 52 EXPECT_EQ(plaintext, result);
53 53
54 // Test Unicode. 54 // Test Unicode.
55 char16 wchars[] = { 0xdbeb, 0xdf1b, 0x4e03, 0x6708, 0x8849, 55 base::char16 wchars[] = { 0xdbeb, 0xdf1b, 0x4e03, 0x6708, 0x8849,
56 0x661f, 0x671f, 0x56db, 0x597c, 0x4e03, 56 0x661f, 0x671f, 0x56db, 0x597c, 0x4e03,
57 0x6708, 0x56db, 0x6708, 0xe407, 0xdbaf, 57 0x6708, 0x56db, 0x6708, 0xe407, 0xdbaf,
58 0xdeb5, 0x4ec5, 0x544b, 0x661f, 0x671f, 58 0xdeb5, 0x4ec5, 0x544b, 0x661f, 0x671f,
59 0x65e5, 0x661f, 0x671f, 0x4e94, 0xd8b1, 59 0x65e5, 0x661f, 0x671f, 0x4e94, 0xd8b1,
60 0xdce1, 0x7052, 0x5095, 0x7c0b, 0xe586, 0}; 60 0xdce1, 0x7052, 0x5095, 0x7c0b, 0xe586, 0};
61 plaintext = wchars; 61 plaintext = wchars;
62 utf8_plaintext = base::UTF16ToUTF8(plaintext); 62 utf8_plaintext = base::UTF16ToUTF8(plaintext);
63 EXPECT_EQ(plaintext, base::UTF8ToUTF16(utf8_plaintext)); 63 EXPECT_EQ(plaintext, base::UTF8ToUTF16(utf8_plaintext));
64 EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext)); 64 EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
65 EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result)); 65 EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
66 EXPECT_EQ(plaintext, result); 66 EXPECT_EQ(plaintext, result);
67 EXPECT_TRUE(Encryptor::DecryptString(ciphertext, &utf8_result)); 67 EXPECT_TRUE(Encryptor::DecryptString(ciphertext, &utf8_result));
68 EXPECT_EQ(utf8_plaintext, base::UTF16ToUTF8(result)); 68 EXPECT_EQ(utf8_plaintext, base::UTF16ToUTF8(result));
69 69
70 EXPECT_TRUE(Encryptor::EncryptString(utf8_plaintext, &ciphertext)); 70 EXPECT_TRUE(Encryptor::EncryptString(utf8_plaintext, &ciphertext));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext)); 134 ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
135 EXPECT_NE(plaintext, ciphertext); 135 EXPECT_NE(plaintext, ciphertext);
136 ASSERT_LT(4UL, ciphertext.size()); 136 ASSERT_LT(4UL, ciphertext.size());
137 ciphertext[3] = ciphertext[3] + 1; 137 ciphertext[3] = ciphertext[3] + 1;
138 EXPECT_FALSE(Encryptor::DecryptString(ciphertext, &result)); 138 EXPECT_FALSE(Encryptor::DecryptString(ciphertext, &result));
139 EXPECT_NE(plaintext, result); 139 EXPECT_NE(plaintext, result);
140 EXPECT_TRUE(result.empty()); 140 EXPECT_TRUE(result.empty());
141 } 141 }
142 142
143 } // namespace 143 } // namespace
OLDNEW
« no previous file with comments | « components/sessions/serialized_navigation_entry.cc ('k') | content/browser/accessibility/browser_accessibility_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698