• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 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 #pragma once
15 
16 // DOCSTAG: [pw_allocator-examples-custom_allocator-test_harness]
17 #include <cstddef>
18 
19 #include "examples/custom_allocator.h"
20 #include "pw_allocator/test_harness.h"
21 #include "pw_allocator/testing.h"
22 
23 namespace examples {
24 
25 class CustomAllocatorTestHarness : public pw::allocator::test::TestHarness<64> {
26  public:
27   static constexpr size_t kCapacity = 0x1000;
28   static constexpr size_t kThreshold = 0x800;
29 
CustomAllocatorTestHarness()30   CustomAllocatorTestHarness() : custom_(allocator_, kThreshold) {}
31   ~CustomAllocatorTestHarness() override = default;
32 
Init()33   pw::Allocator* Init() override { return &custom_; }
34 
35  private:
36   pw::allocator::test::AllocatorForTest<kCapacity> allocator_;
37   CustomAllocator custom_;
38 };
39 
40 }  // namespace examples
41