Remove errant '>' in gyp file.
[chromium-blink-merge.git] / rlz / lib / crc32_unittest.cc
blob9700058754cc27acb313262f59570eedbb80137c
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.
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) {
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},
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));
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},
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);