bitmap-test-utils.h 968 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_
#define V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_

#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {
namespace internal {

template <typename T>
class TestWithBitmap : public ::testing::Test {
 public:
  TestWithBitmap() : memory_(new uint8_t[Bitmap::kSize]) {
    memset(memory_, 0, Bitmap::kSize);
  }

  ~TestWithBitmap() override { delete[] memory_; }

  T* bitmap() { return reinterpret_cast<T*>(memory_); }
  uint8_t* raw_bitmap() { return memory_; }

 private:
  uint8_t* memory_;
};

using BitmapTypes = ::testing::Types<ConcurrentBitmap<AccessMode::NON_ATOMIC>,
                                     ConcurrentBitmap<AccessMode::ATOMIC>>;

}  // namespace internal
}  // namespace v8

#endif  // V8_UNITTESTS_HEAP_BITMAP_TEST_UTILS_H_