Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/common/aligned_memory_unittest.cpp
1693 views
1
//
2
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// aligned_memory_unittests: Tests for the aligned memory allocator.
7
// Tests copied from Chrome: src/base/memory/aligned_memory_unittests.cc.
8
//
9
10
#include "common/aligned_memory.h"
11
12
#include <memory>
13
14
#include "gtest/gtest.h"
15
16
#define EXPECT_ALIGNED(ptr, align) EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1))
17
18
namespace angle
19
{
20
21
// Test that dynamic allocation works as expected.
22
TEST(AlignedMemoryTest, DynamicAllocation)
23
{
24
void *p = AlignedAlloc(8, 8);
25
EXPECT_TRUE(p);
26
EXPECT_ALIGNED(p, 8);
27
AlignedFree(p);
28
29
p = AlignedAlloc(8, 16);
30
EXPECT_TRUE(p);
31
EXPECT_ALIGNED(p, 16);
32
AlignedFree(p);
33
34
p = AlignedAlloc(8, 256);
35
EXPECT_TRUE(p);
36
EXPECT_ALIGNED(p, 256);
37
AlignedFree(p);
38
39
p = AlignedAlloc(8, 4096);
40
EXPECT_TRUE(p);
41
EXPECT_ALIGNED(p, 4096);
42
AlignedFree(p);
43
}
44
45
} // namespace angle
46
47