8 #include "flutter/testing/testing.h"
14 TEST(AllocationTest, ReserveNPOTPotentialOverflow) {
15 std::vector<uint8_t> data(64, 0xff);
17 auto allocate_and_write = [&](uint64_t size) {
27 memcpy(allocation.
GetBuffer(), data.data(), data.size());
28 EXPECT_EQ(memcmp(allocation.
GetBuffer(), data.data(), data.size()), 0);
32 allocate_and_write((1ULL << 32) + 1);
33 allocate_and_write((1ULL << 32) - 1);
38 max_allocation.
Truncate(
Bytes{std::numeric_limits<uint64_t>::max()}));
41 TEST(AllocationTest, NextPowerOfTwoSize) {
46 absl::StatusCode::kInvalidArgument);
50 absl::StatusCode::kInvalidArgument);
Describes an allocation on the heap.
uint8_t * GetBuffer() const
Gets the pointer to the start of the allocation.
static absl::StatusOr< uint64_t > NextPowerOfTwoSize(uint64_t x)
Gets the next power of two size.
bool Truncate(Bytes length, bool npot=true)
Resize the underlying allocation to at least given number of bytes.
TEST(AllocationSizeTest, CanCreateTypedAllocations)