chromium/v8/test/unittests/heap/cppgc/finalizer-trait-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 "include/cppgc/internal/finalizer-trait.h"

#include <type_traits>

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

namespace cppgc {
namespace internal {

namespace {

// Trivially destructible types.
class TypeWithoutDestructor final {};
class TypeWithPrimitive final {};

class InvokeCounter {};

size_t InvokeCounter::kCallcount =;

// Regular C++ use cases.

class TypeWithDestructor final : public InvokeCounter {};

class TypeWithVirtualDestructorBase {};

class TypeWithVirtualDestructorChild final
    : public TypeWithVirtualDestructorBase,
      public InvokeCounter {};

// Manual dispatch to avoid vtables.

class TypeWithCustomFinalizationMethod final : public InvokeCounter {};

class TypeWithCustomFinalizationMethodAtBase {};

class TypeWithCustomFinalizationMethodAtBaseChild
    : public TypeWithCustomFinalizationMethodAtBase,
      public InvokeCounter {};

void TypeWithCustomFinalizationMethodAtBase::FinalizeGarbageCollectedObject() {}

template <typename Type>
void ExpectFinalizerIsInvoked(Type* object) {}

}  // namespace

TEST(FinalizerTrait, TypeWithoutDestructorHasNoFinalizer) {}

TEST(FinalizerTrait, TypeWithPrimitiveHasNoFinalizer) {}

TEST(FinalizerTrait, FinalizerForTypeWithDestructor) {}

TEST(FinalizerTrait, FinalizerForTypeWithVirtualBaseDtor) {}

TEST(FinalizerTrait, FinalizerForCustomFinalizationMethod) {}

TEST(FinalizerTrait, FinalizerForCustomFinalizationMethodInBase) {}

}  // namespace internal
}  // namespace cppgc