• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/metrics/crc32.h"
6 
7 #include <stdint.h>
8 
9 #include <array>
10 
11 #include "base/containers/span.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 
14 namespace base {
15 
TEST(Crc32Test,ZeroTest)16 TEST(Crc32Test, ZeroTest) {
17   span<const uint8_t> empty_data;
18   EXPECT_EQ(0U, Crc32(0, empty_data));
19 }
20 
TEST(Crc32Test,EmptyNonzeroTest)21 TEST(Crc32Test, EmptyNonzeroTest) {
22   span<const uint8_t> empty_data;
23   EXPECT_EQ(99U, Crc32(99, empty_data));
24 }
25 
TEST(Crc32Test,NonemptyTest)26 TEST(Crc32Test, NonemptyTest) {
27   std::array<uint8_t, 5> arr = {1, 2, 3, 4, 5};
28   EXPECT_EQ(0x81296ee9U, Crc32(0, arr));
29 }
30 
31 }  // namespace base
32