• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include "pw_allocator/block/detailed_block.h"
16 
17 #include <cstdint>
18 
19 #include "pw_allocator/block/unit_tests.h"
20 
21 namespace {
22 
23 // Use a very small offset type to test failure of an overly large block without
24 // requiring excessive memory for the test.
25 
26 using TinyOffsetDetailedBlock = ::pw::allocator::DetailedBlock<uint8_t>;
27 using TinyOffsetDetailedBlockTest =
28     ::pw::allocator::test::BlockTest<TinyOffsetDetailedBlock>;
29 
TEST_F(TinyOffsetDetailedBlockTest,CannotCreateTooLargeBlock)30 TEST_F(TinyOffsetDetailedBlockTest, CannotCreateTooLargeBlock) {
31   CannotCreateTooLargeBlock();
32 }
33 
34 // Unit tests for DetailedBlock with a small offset field.
35 
36 using SmallOffsetDetailedBlock = ::pw::allocator::DetailedBlock<uint16_t>;
37 using SmallOffsetDetailedBlockTest =
38     ::pw::allocator::test::BlockTest<SmallOffsetDetailedBlock>;
39 
40 PW_ALLOCATOR_BASIC_BLOCK_TESTS(SmallOffsetDetailedBlockTest)
41 PW_ALLOCATOR_ALLOCATABLE_BLOCK_TESTS(SmallOffsetDetailedBlockTest)
42 PW_ALLOCATOR_ALIGNABLE_BLOCK_TESTS(SmallOffsetDetailedBlockTest)
43 PW_ALLOCATOR_POISONABLE_BLOCK_TESTS(SmallOffsetDetailedBlockTest)
44 PW_ALLOCATOR_BLOCK_WITH_LAYOUT_TESTS(SmallOffsetDetailedBlockTest)
45 
46 // Unit tests for DetailedBlock with a large offset field.
47 
48 using LargeOffsetDetailedBlock = ::pw::allocator::DetailedBlock<uint64_t>;
49 using LargeOffsetDetailedBlockTest =
50     ::pw::allocator::test::BlockTest<LargeOffsetDetailedBlock>;
51 
52 PW_ALLOCATOR_BASIC_BLOCK_TESTS(LargeOffsetDetailedBlockTest)
53 PW_ALLOCATOR_ALLOCATABLE_BLOCK_TESTS(LargeOffsetDetailedBlockTest)
54 PW_ALLOCATOR_ALIGNABLE_BLOCK_TESTS(LargeOffsetDetailedBlockTest)
55 PW_ALLOCATOR_POISONABLE_BLOCK_TESTS(LargeOffsetDetailedBlockTest)
56 PW_ALLOCATOR_BLOCK_WITH_LAYOUT_TESTS(LargeOffsetDetailedBlockTest)
57 
58 }  // namespace
59