this repo has no description
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
2#include "space.h"
3
4#include "gtest/gtest.h"
5
6namespace py {
7
8TEST(SpaceTest, Allocate) {
9 Space space(64 * kKiB);
10 EXPECT_EQ(space.start(), space.fill());
11 EXPECT_LT(space.start(), space.end());
12 EXPECT_TRUE(space.contains(space.start()));
13 EXPECT_FALSE(space.isAllocated(space.fill()));
14 EXPECT_FALSE(space.contains(space.end()));
15
16 uword address;
17 EXPECT_TRUE(space.allocate(10 * kPointerSize, &address));
18 EXPECT_TRUE(space.isAllocated(address));
19 EXPECT_FALSE(space.isAllocated(space.fill()));
20
21 EXPECT_EQ(space.start(), address);
22 EXPECT_LT(space.start(), space.fill());
23 EXPECT_LT(space.fill(), space.end());
24 EXPECT_TRUE(space.contains(address));
25 EXPECT_TRUE(space.contains(space.fill()));
26 EXPECT_FALSE(space.isAllocated(space.fill()));
27
28 space.reset();
29 EXPECT_FALSE(space.isAllocated(address));
30 EXPECT_EQ(space.start(), space.fill());
31}
32
33} // namespace py