|
|
|
@ -1310,6 +1310,26 @@ TEST(CppGeneratedCode, SetAliasFailsForDifferentArena) { |
|
|
|
|
EXPECT_DEATH(parent.set_alias_child(child), "hpb::interop::upb::GetArena"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(CppGeneratedCode, SetAliasSucceedsForDifferentArenaFused) { |
|
|
|
|
hpb::Arena arena; |
|
|
|
|
auto parent1 = hpb::CreateMessage<Parent>(arena); |
|
|
|
|
auto child = parent1.mutable_child(); |
|
|
|
|
child->set_peeps(12); |
|
|
|
|
|
|
|
|
|
hpb::Arena other_arena; |
|
|
|
|
auto parent2 = hpb::CreateMessage<Parent>(other_arena); |
|
|
|
|
arena.Fuse(other_arena); |
|
|
|
|
|
|
|
|
|
parent2.set_alias_child(child); |
|
|
|
|
|
|
|
|
|
ASSERT_EQ(parent1.child()->peeps(), parent2.child()->peeps()); |
|
|
|
|
ASSERT_EQ(hpb::interop::upb::GetMessage(parent1.child()), |
|
|
|
|
hpb::interop::upb::GetMessage(parent2.child())); |
|
|
|
|
auto childPtr = hpb::Ptr<Child>(child); |
|
|
|
|
ASSERT_EQ(hpb::interop::upb::GetMessage(childPtr), |
|
|
|
|
hpb::interop::upb::GetMessage(parent1.child())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(CppGeneratedCode, SetAliasRepeated) { |
|
|
|
|
hpb::Arena arena; |
|
|
|
|
auto child = hpb::CreateMessage<Child>(arena); |
|
|
|
|