Skip to content

Commit 77a79fe

Browse files
committed
Add large 1mb buffer test for crc32 hashing.
1 parent e4a31e0 commit 77a79fe

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/test_crc32.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,29 @@ class crc32_align : public ::testing::TestWithParam<int> {
227227
}
228228
};
229229

230+
/* Test large 1MB buffer with known CRC32 */
231+
class crc32_large_buf : public ::testing::Test {
232+
protected:
233+
static uint8_t *buffer;
234+
static const size_t buffer_size = 1024 * 1024;
235+
236+
static void SetUpTestSuite() {
237+
buffer = (uint8_t*)zng_alloc(buffer_size);
238+
memset(buffer, 0x55, buffer_size);
239+
}
240+
241+
static void TearDownTestSuite() {
242+
zng_free(buffer);
243+
}
244+
245+
public:
246+
void hash(crc32_func crc32) {
247+
EXPECT_EQ(crc32(0, buffer, buffer_size), 0x0026D5FB);
248+
}
249+
};
250+
251+
uint8_t *crc32_large_buf::buffer = nullptr;
252+
230253
INSTANTIATE_TEST_SUITE_P(crc32, crc32_variant, testing::ValuesIn(tests));
231254

232255
#define TEST_CRC32(name, func, support_flag) \
@@ -236,6 +259,13 @@ INSTANTIATE_TEST_SUITE_P(crc32, crc32_variant, testing::ValuesIn(tests));
236259
return; \
237260
} \
238261
hash(GetParam(), func); \
262+
} \
263+
TEST_F(crc32_large_buf, name) { \
264+
if (!(support_flag)) { \
265+
GTEST_SKIP(); \
266+
return; \
267+
} \
268+
hash(func); \
239269
}
240270

241271
#ifndef WITHOUT_CHORBA

0 commit comments

Comments
 (0)