summaryrefslogtreecommitdiff
path: root/absl/crc/crc32c_test.cc
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2022-11-30 10:58:38 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2022-11-30 10:59:21 -0800
commit66665d8d2e3fedff340b83f9841ca427145a7b26 (patch)
tree747602a57a578dc3220d8e61298184c43bbf8deb /absl/crc/crc32c_test.cc
parent94e9ee3f75a617403049a29e6c932b8b3bb13177 (diff)
Fixes many compilation issues that come from having no external CI
coverage of the accelerated CRC implementation and some differences bewteen the internal and external implementation. This change adds CI coverage to the linux_clang-latest_libstdcxx_bazel.sh script assuming this script always runs on machines of at least the Intel Haswell generation. Fixes include: * Remove the use of the deprecated xor operator on crc32c_t * Remove #pragma unroll_completely, which isn't known by GCC or Clang: https://godbolt.org/z/97j4vbacs * Fixes for -Wsign-compare, -Wsign-conversion and -Wshorten-64-to-32 PiperOrigin-RevId: 491965029 Change-Id: Ic5e1f3a20f69fcd35fe81ebef63443ad26bf7931
Diffstat (limited to 'absl/crc/crc32c_test.cc')
-rw-r--r--absl/crc/crc32c_test.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/absl/crc/crc32c_test.cc b/absl/crc/crc32c_test.cc
index 0b9dc683..72d422a1 100644
--- a/absl/crc/crc32c_test.cc
+++ b/absl/crc/crc32c_test.cc
@@ -15,6 +15,7 @@
#include "absl/crc/crc32c.h"
#include <algorithm>
+#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
@@ -90,7 +91,8 @@ TEST(CRC32C, ExtendByZeroes) {
std::string base = "hello world";
absl::crc32c_t base_crc = absl::crc32c_t{0xc99465aa};
- for (const size_t extend_by : {100, 10000, 100000}) {
+ constexpr size_t kExtendByValues[] = {100, 10000, 100000};
+ for (const size_t extend_by : kExtendByValues) {
SCOPED_TRACE(extend_by);
absl::crc32c_t crc2 = absl::ExtendCrc32cByZeroes(base_crc, extend_by);
EXPECT_EQ(crc2, absl::ComputeCrc32c(base + std::string(extend_by, '\0')));
@@ -98,10 +100,13 @@ TEST(CRC32C, ExtendByZeroes) {
}
TEST(CRC32C, UnextendByZeroes) {
+ constexpr size_t kExtendByValues[] = {2, 200, 20000, 200000, 20000000};
+ constexpr size_t kUnextendByValues[] = {0, 100, 10000, 100000, 10000000};
+
for (auto seed_crc : {absl::crc32c_t{0}, absl::crc32c_t{0xc99465aa}}) {
SCOPED_TRACE(seed_crc);
- for (const size_t size_1 : {2, 200, 20000, 200000, 20000000}) {
- for (const size_t size_2 : {0, 100, 10000, 100000, 10000000}) {
+ for (const size_t size_1 : kExtendByValues) {
+ for (const size_t size_2 : kUnextendByValues) {
size_t extend_size = std::max(size_1, size_2);
size_t unextend_size = std::min(size_1, size_2);
SCOPED_TRACE(extend_size);
@@ -120,7 +125,9 @@ TEST(CRC32C, UnextendByZeroes) {
}
}
}
- for (const size_t size : {0, 1, 100, 10000}) {
+
+ constexpr size_t kSizes[] = {0, 1, 100, 10000};
+ for (const size_t size : kSizes) {
SCOPED_TRACE(size);
std::string string_before = TestString(size);
std::string string_after = string_before + std::string(size, '\0');
@@ -146,7 +153,8 @@ TEST(CRC32C, Concat) {
}
TEST(CRC32C, Memcpy) {
- for (size_t bytes : {0, 1, 20, 500, 100000}) {
+ constexpr size_t kBytesSize[] = {0, 1, 20, 500, 100000};
+ for (size_t bytes : kBytesSize) {
SCOPED_TRACE(bytes);
std::string sample_string = TestString(bytes);
std::string target_buffer = std::string(bytes, '\0');