chromium/v8/test/unittests/heap/cppgc/weak-container-unittest.cc

// Copyright 2020 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.

#include <atomic>

#include "include/cppgc/allocation.h"
#include "src/base/macros.h"
#include "src/heap/cppgc/marker.h"
#include "src/heap/cppgc/marking-visitor.h"
#include "src/heap/cppgc/stats-collector.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {
class WeakContainerTest : public testing::TestWithHeap {};

template <typename T>
constexpr size_t SizeOf() {}

class TraceableGCed : public GarbageCollected<TraceableGCed> {};

class NonTraceableGCed : public GarbageCollected<NonTraceableGCed> {};

void EmptyWeakCallback(const LivenessBroker&, const void*) {}

}  // namespace

}  // namespace internal

template <>
struct TraceTrait<internal::TraceableGCed>
    : public internal::TraceTraitBase<internal::TraceableGCed> {};

template <>
struct TraceTrait<internal::NonTraceableGCed>
    : public internal::TraceTraitBase<internal::NonTraceableGCed> {};

namespace internal {

TEST_F(WeakContainerTest, TraceableGCedTraced) {}

TEST_F(WeakContainerTest, NonTraceableGCedNotTraced) {}

TEST_F(WeakContainerTest, NonTraceableGCedNotTracedConservatively) {}

TEST_F(WeakContainerTest, PreciseGCTracesWeakContainerWhenTraced) {}

TEST_F(WeakContainerTest, ConservativeGCTracesWeakContainer) {}

TEST_F(WeakContainerTest, ConservativeGCTracesWeakContainerOnce) {}

namespace {

struct WeakCallback {};
size_t WeakCallback::n_callback_called =;
const void* WeakCallback::obj =;

}  // namespace

TEST_F(WeakContainerTest, WeakContainerWeakCallbackCalled) {}

}  // namespace internal
}  // namespace cppgc