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.
5 // A test for ZLib's checksum function.
7 #include "rlz/lib/crc32.h"
9 #include "base/logging.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(Crc32Unittest
, ByteTest
) {
17 // Externally calculated at http://crc32-checksum.waraxe.us/
20 {"Hello" , 5, 0xF7D18982},
21 {"Google" , 6, 0x62B0F067},
23 {"One more string.", 16, 0x0CA14970},
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
),
33 TEST(Crc32Unittest
, CharTest
) {
36 // Externally calculated at http://crc32-checksum.waraxe.us/
39 {"Hello" , 0xF7D18982},
40 {"Google" , 0x62B0F067},
42 {"One more string.", 0x0CA14970},
43 {"Google\r\n" , 0x83A3E860},
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
);