Line data Source code
1 : // Copyright 2019 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_
6 : #define V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_
7 :
8 : #include "testing/gtest/include/gtest/gtest.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 :
13 : template <typename T>
14 : class TestWithBitmap : public ::testing::Test {
15 : public:
16 19 : TestWithBitmap() : memory_(new uint8_t[Bitmap::kSize]) {
17 : memset(memory_, 0, Bitmap::kSize);
18 19 : }
19 :
20 19 : ~TestWithBitmap() override { delete[] memory_; }
21 :
22 : T* bitmap() { return reinterpret_cast<T*>(memory_); }
23 : uint8_t* raw_bitmap() { return memory_; }
24 :
25 : private:
26 : uint8_t* memory_;
27 : };
28 :
29 : using BitmapTypes = ::testing::Types<ConcurrentBitmap<AccessMode::NON_ATOMIC>,
30 : ConcurrentBitmap<AccessMode::ATOMIC>>;
31 :
32 : } // namespace internal
33 : } // namespace v8
34 :
35 : #endif // V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_
|