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

Side by Side Diff: rlz/lib/crc32_unittest.cc

Issue 10642009: Add a regenerate button to regenerate the password in Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync and Merge. Created 8 years, 5 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 | « rlz/lib/crc32.h ('k') | rlz/lib/crc32_wrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // A test for ZLib's checksum function.
6
7 #include "rlz/lib/crc32.h"
8
9 #include "base/logging.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 TEST(Crc32Unittest, ByteTest) {
14 struct {
15 const char* data;
16 int len;
17 // Externally calculated at http://crc32-checksum.waraxe.us/
18 int crc;
19 } kData[] = {
20 {"Hello" , 5, 0xF7D18982},
21 {"Google" , 6, 0x62B0F067},
22 {"" , 0, 0x0},
23 {"One more string.", 16, 0x0CA14970},
24 {NULL , 0, 0x0},
25 };
26
27 for (int i = 0; kData[i].data; i++)
28 EXPECT_EQ(kData[i].crc,
29 rlz_lib::Crc32(reinterpret_cast<const unsigned char*>(kData[i].data),
30 kData[i].len));
31 }
32
33 TEST(Crc32Unittest, CharTest) {
34 struct {
35 const char* data;
36 // Externally calculated at http://crc32-checksum.waraxe.us/
37 int crc;
38 } kData[] = {
39 {"Hello" , 0xF7D18982},
40 {"Google" , 0x62B0F067},
41 {"" , 0x0},
42 {"One more string.", 0x0CA14970},
43 {"Google\r\n" , 0x83A3E860},
44 {NULL , 0x0},
45 };
46
47 int crc;
48 for (int i = 0; kData[i].data; i++) {
49 EXPECT_TRUE(rlz_lib::Crc32(kData[i].data, &crc));
50 EXPECT_EQ(kData[i].crc, crc);
51 }
52 }
OLDNEW
« no previous file with comments | « rlz/lib/crc32.h ('k') | rlz/lib/crc32_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698