summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/test/TestCrc32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/utils/test/TestCrc32.cpp')
-rw-r--r--xbmc/utils/test/TestCrc32.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/xbmc/utils/test/TestCrc32.cpp b/xbmc/utils/test/TestCrc32.cpp
new file mode 100644
index 0000000..99a2dd5
--- /dev/null
+++ b/xbmc/utils/test/TestCrc32.cpp
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#include "utils/Crc32.h"
10
11#include <gtest/gtest.h>
12
13static const char refdata[] = "abcdefghijklmnopqrstuvwxyz"
14 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
15 "01234567890!@#$%^&*()";
16
17TEST(TestCrc32, Compute_1)
18{
19 Crc32 a;
20 uint32_t varcrc;
21 a.Compute(refdata, sizeof(refdata) - 1);
22 varcrc = a;
23 EXPECT_EQ(0xa4eb60e3, varcrc);
24}
25
26TEST(TestCrc32, Compute_2)
27{
28 uint32_t varcrc;
29 std::string s = refdata;
30 varcrc = Crc32::Compute(s);
31 EXPECT_EQ(0xa4eb60e3, varcrc);
32}
33
34TEST(TestCrc32, ComputeFromLowerCase)
35{
36 std::string s = refdata;
37 uint32_t varcrc = Crc32::ComputeFromLowerCase(s);
38 EXPECT_EQ((uint32_t)0x7f045b3e, varcrc);
39}
40
41TEST(TestCrc32, Reset)
42{
43 Crc32 a;
44 uint32_t varcrc;
45 std::string s = refdata;
46 a.Compute(s.c_str(), s.length());
47 a.Reset();
48 varcrc = a;
49 EXPECT_EQ(0xffffffff, varcrc);
50}