#include "catch2/catch.hpp"
#include "cetlib/crc32.h"
#include <string>
#include "CRC32Calculator.h"
Go to the source code of this file.
|
| SCENARIO ("We can produce CRC32 checksums accurately") |
|
SCENARIO |
( |
"We can produce CRC32 checksums accurately" |
| ) |
|
Definition at line 52 of file crc32_test.cc.
56 GIVEN(
"We have a short string")
58 WHEN(
"We create CRC32 digests in two different ways")
63 auto const digest = crc.
digest();
64 auto const ref = refMaker.checksum();
66 THEN(
"The checksums compare equal") { CHECK(digest == ref); }
70 GIVEN(
"We have a longer string")
72 WHEN(
"We create CRC32 digests in two different ways")
77 auto const digest = crc.
digest();
78 auto const ref = refMaker.checksum();
80 THEN(
"The checksums compare equal") { CHECK(digest == ref); }
84 GIVEN(
"We have a *much* longer string")
86 WHEN(
"We create CRC32 digests in two different ways")
91 auto const digest = crc.
digest();
92 auto const ref = refMaker.checksum();
94 THEN(
"The checksums compare equal") { CHECK(digest == ref); }
98 GIVEN(
"We have a string with a known, externally calculated CRC32 checksum")
100 WHEN(
"We create CRC32 digests in two different ways")
102 auto const testString =
"type_label_instance"s;
103 auto const process_suffix =
"_process"s;
104 auto const knownResult = 1215348599u;
106 crc << (testString + process_suffix);
109 auto const digest = crc.
digest();
110 auto const ref = refMaker.checksum();
112 THEN(
"All three checksums compare equal")
114 CHECK(digest == knownResult);
115 CHECK(digest == ref);
117 WHEN(
"We insert more text before calculating a digest")
119 crc32 crc_insert(testString);
120 crc_insert << process_suffix;
122 THEN(
"We get the same answer")
124 CHECK(crc_insert.digest() == knownResult);
130 GIVEN(
"We have an empty string")
132 WHEN(
"We calculate its CRC32 checksum")
136 THEN(
"It should be 0") { CHECK(crc.
digest() == 0); }
constexpr digest_t digest() const