NodeId id = 1L << 33; uint64_t size = 1L << 60; MockDeserializedNode mocked(id, typeName, size); mocked.jsObjectClassName = mozilla::UniquePtr<char[]>(strdup(className)); ASSERT_TRUE(!!mocked.jsObjectClassName); DeserializedNode& deserialized = mocked; JS::ubi::Node ubi(&deserialized); // Test the ubi::Node accessors. EXPECT_EQ(size, ubi.size(fakeMallocSizeOf)); EXPECT_EQ(typeName, ubi.typeName()); EXPECT_EQ(id, ubi.identifier()); EXPECT_FALSE(ubi.isLive()); EXPECT_EQ(strcmp(ubi.jsObjectClassName(), className), 0); // Test the ubi::Node's edges. UniquePtr<DeserializedNode> referent1(new MockDeserializedNode(1, nullptr, 10)); DeserializedEdge edge1; edge1.referent = referent1->id; mocked.addEdge(Move(edge1)); EXPECT_CALL(mocked, getEdgeReferent(Field(&DeserializedEdge::referent, referent1->id))) .Times(1) .WillOnce(Return(JS::ubi::Node(referent1.get())));
uint64_t size = uint64_t(1) << 60; MockDeserializedNode mocked(id, typeName, size); mocked.coarseType = JS::ubi::CoarseType::Script; mocked.jsObjectClassName = className; DeserializedNode& deserialized = mocked; JS::ubi::Node ubi(&deserialized); // Test the ubi::Node accessors. EXPECT_EQ(size, ubi.size(fakeMallocSizeOf)); EXPECT_EQ(typeName, ubi.typeName()); EXPECT_EQ(JS::ubi::CoarseType::Script, ubi.coarseType()); EXPECT_EQ(id, ubi.identifier()); EXPECT_FALSE(ubi.isLive()); EXPECT_EQ(ubi.jsObjectClassName(), className); // Test the ubi::Node's edges. UniquePtr<DeserializedNode> referent1(new MockDeserializedNode(1, nullptr, 10)); DeserializedEdge edge1(referent1->id); mocked.addEdge(Move(edge1)); EXPECT_CALL(mocked, getEdgeReferent(Field(&DeserializedEdge::referent, referent1->id))) .Times(1) .WillOnce(Return(JS::ubi::Node(referent1.get()))); UniquePtr<DeserializedNode> referent2(new MockDeserializedNode(2,