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

Side by Side Diff: base/md5_unittest.cc

Issue 632103004: Cleanup: Better constify some strings in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad refactoring Created 6 years, 2 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
« no previous file with comments | « base/mac/mac_util_unittest.mm ('k') | base/metrics/field_trial_unittest.cc » ('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) 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 <string.h> 5 #include <string.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 15 matching lines...) Expand all
26 digest.a[i] = data[i] & 0xff; 26 digest.a[i] = data[i] & 0xff;
27 27
28 std::string actual = MD5DigestToBase16(digest); 28 std::string actual = MD5DigestToBase16(digest);
29 std::string expected = "d41d8cd98f00b204e9800998ecf8427e"; 29 std::string expected = "d41d8cd98f00b204e9800998ecf8427e";
30 30
31 EXPECT_EQ(expected, actual); 31 EXPECT_EQ(expected, actual);
32 } 32 }
33 33
34 TEST(MD5, MD5SumEmtpyData) { 34 TEST(MD5, MD5SumEmtpyData) {
35 MD5Digest digest; 35 MD5Digest digest;
36 const char* data = ""; 36 const char data[] = "";
37 37
38 MD5Sum(data, strlen(data), &digest); 38 MD5Sum(data, strlen(data), &digest);
39 39
40 int expected[] = { 40 int expected[] = {
41 0xd4, 0x1d, 0x8c, 0xd9, 41 0xd4, 0x1d, 0x8c, 0xd9,
42 0x8f, 0x00, 0xb2, 0x04, 42 0x8f, 0x00, 0xb2, 0x04,
43 0xe9, 0x80, 0x09, 0x98, 43 0xe9, 0x80, 0x09, 0x98,
44 0xec, 0xf8, 0x42, 0x7e 44 0xec, 0xf8, 0x42, 0x7e
45 }; 45 };
46 46
47 for (int i = 0; i < 16; ++i) 47 for (int i = 0; i < 16; ++i)
48 EXPECT_EQ(expected[i], digest.a[i] & 0xFF); 48 EXPECT_EQ(expected[i], digest.a[i] & 0xFF);
49 } 49 }
50 50
51 TEST(MD5, MD5SumOneByteData) { 51 TEST(MD5, MD5SumOneByteData) {
52 MD5Digest digest; 52 MD5Digest digest;
53 const char* data = "a"; 53 const char data[] = "a";
54 54
55 MD5Sum(data, strlen(data), &digest); 55 MD5Sum(data, strlen(data), &digest);
56 56
57 int expected[] = { 57 int expected[] = {
58 0x0c, 0xc1, 0x75, 0xb9, 58 0x0c, 0xc1, 0x75, 0xb9,
59 0xc0, 0xf1, 0xb6, 0xa8, 59 0xc0, 0xf1, 0xb6, 0xa8,
60 0x31, 0xc3, 0x99, 0xe2, 60 0x31, 0xc3, 0x99, 0xe2,
61 0x69, 0x77, 0x26, 0x61 61 0x69, 0x77, 0x26, 0x61
62 }; 62 };
63 63
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 // The header and full digest pairs are the same, and they aren't the same as 244 // The header and full digest pairs are the same, and they aren't the same as
245 // each other. 245 // each other.
246 EXPECT_TRUE(!memcmp(&header_digest, &check_header_digest, 246 EXPECT_TRUE(!memcmp(&header_digest, &check_header_digest,
247 sizeof(header_digest))); 247 sizeof(header_digest)));
248 EXPECT_TRUE(!memcmp(&digest, &check_full_digest, sizeof(digest))); 248 EXPECT_TRUE(!memcmp(&digest, &check_full_digest, sizeof(digest)));
249 EXPECT_FALSE(!memcmp(&digest, &header_digest, sizeof(digest))); 249 EXPECT_FALSE(!memcmp(&digest, &header_digest, sizeof(digest)));
250 } 250 }
251 251
252 } // namespace base 252 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util_unittest.mm ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698