commit | a7430c19e0d18b38c1432eb5f5a06331ee4d1748 | [log] [tgz] |
---|---|---|
author | Lei Zhang <thestig@chromium.org> | Wed Apr 01 20:57:14 2020 +0000 |
committer | Chromium commit bot <commit-bot@chromium.org> | Wed Apr 01 20:57:14 2020 +0000 |
tree | 16b936045a425c09f3bdaf001cbd05bb9249cd5a | |
parent | b76bc8aedde30bf6a99ec4997af6be7a2c8939b5 [diff] |
Add a unit test for FX_Alloc(). Make sure it returns zeroed out memory. Change-Id: Ie63f03373a2a281ce0719320132217b782f06f2e Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/68151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/fx_memory_unittest.cpp b/core/fxcrt/fx_memory_unittest.cpp index b3fd299..395632b 100644 --- a/core/fxcrt/fx_memory_unittest.cpp +++ b/core/fxcrt/fx_memory_unittest.cpp
@@ -94,6 +94,14 @@ FXMEM_DefaultFree(ptr); } +TEST(fxcrt, AllocZeroesMemory) { + uint8_t* ptr = FX_Alloc(uint8_t, 32); + ASSERT_TRUE(ptr); + for (size_t i = 0; i < 32; ++i) + EXPECT_EQ(0, ptr[i]); + FX_Free(ptr); +} + TEST(fxcrt, FXAlign) { static_assert(std::numeric_limits<size_t>::max() % 2 == 1, "numeric limit must be odd for this test");