node/deps/v8/test/unittests/heap/cppgc/object-size-trait-unittest.cc
Michaël Zasso 732ad99e47
deps: update V8 to 9.0.257.11
PR-URL: https://github.com/nodejs/node/pull/37587
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2021-03-15 15:54:50 +01:00

52 lines
1.5 KiB
C++

// 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/object-size-trait.h"
#include "include/cppgc/allocation.h"
#include "include/cppgc/garbage-collected.h"
#include "src/heap/cppgc/heap.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cppgc {
namespace internal {
namespace {
class ObjectSizeTraitTest : public testing::TestWithHeap {};
class GCed : public GarbageCollected<GCed> {
public:
void Trace(Visitor*) const {}
};
class NotGCed {};
class Mixin : public GarbageCollectedMixin {};
class UnmanagedMixinWithDouble {
protected:
virtual void ForceVTable() {}
};
class GCedWithMixin : public GarbageCollected<GCedWithMixin>,
public UnmanagedMixinWithDouble,
public Mixin {};
} // namespace
TEST_F(ObjectSizeTraitTest, GarbageCollected) {
auto* obj = cppgc::MakeGarbageCollected<GCed>(GetAllocationHandle());
EXPECT_GE(subtle::ObjectSizeTrait<GCed>::GetSize(*obj), sizeof(GCed));
}
TEST_F(ObjectSizeTraitTest, GarbageCollectedMixin) {
auto* obj = cppgc::MakeGarbageCollected<GCedWithMixin>(GetAllocationHandle());
Mixin& mixin = static_cast<Mixin&>(*obj);
EXPECT_NE(static_cast<void*>(&mixin), obj);
EXPECT_GE(subtle::ObjectSizeTrait<Mixin>::GetSize(mixin),
sizeof(GCedWithMixin));
}
} // namespace internal
} // namespace cppgc