blob: 32f67ed3a85ff266abb09e749632268b2aa1bb74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <dlib/crc32.h>
#include "tester.h"
namespace
{
using namespace test;
using namespace dlib;
using namespace std;
logger dlog("test.crc32");
class crc32_tester : public tester
{
public:
crc32_tester (
) :
tester ("test_crc32",
"Runs tests on the crc32 component.")
{}
void perform_test (
)
{
DLIB_TEST(crc32("davis").get_checksum() == 0x0445527C);
crc32 c, c2;
DLIB_TEST(c.get_checksum() == 0);
c.add("davis");
DLIB_TEST(c.get_checksum() == 0x0445527C);
DLIB_TEST(c2.get_checksum() == 0);
c2 = c;
DLIB_TEST(c2.get_checksum() == 0x0445527C);
crc32 c3(c);
DLIB_TEST(c3.get_checksum() == 0x0445527C);
c.add('a');
c2.add('a');
c3.add('a');
DLIB_TEST(c.get_checksum() == 0xB100C606);
DLIB_TEST(c2.get_checksum() == 0xB100C606);
DLIB_TEST(c3.get_checksum() == 0xB100C606);
crc32::kernel_1a cold;
DLIB_TEST(cold.get_checksum() == 0);
cold.add("davis");
DLIB_TEST(cold.get_checksum() == 0x0445527C);
c.clear();
DLIB_TEST(c.get_checksum() == 0);
c.add("davis");
DLIB_TEST(c.get_checksum() == 0x0445527C);
std::vector<char> buf;
for (int i = 0; i < 4000; ++i)
buf.push_back(i);
DLIB_TEST(crc32(buf) == 492662731);
}
} a;
}
|