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

Side by Side Diff: chrome/browser/password_manager/encryptor_unittest.cc

Issue 8511050: Unify the error checking of crypto::Encryptor and add WARN_UNUSED_RESULT to prevent misuse. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 8 years, 10 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
« no previous file with comments | « no previous file | crypto/encryptor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/password_manager/encryptor.h" 5 #include "chrome/browser/password_manager/encryptor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::string ciphertext; 130 std::string ciphertext;
131 131
132 // Test a simple string, messing with ciphertext prior to decrypting. 132 // Test a simple string, messing with ciphertext prior to decrypting.
133 plaintext = "hello"; 133 plaintext = "hello";
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());
141 } 140 }
142 141
143 } // namespace 142 } // namespace
OLDNEW
« no previous file with comments | « no previous file | crypto/encryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698