Skip to content

Commit 74afb61

Browse files
committed
Improve field test by preventing copying of top level messages
1 parent 439d4de commit 74afb61

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/mutator_test.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,19 +547,18 @@ void MutatorFieldTest::TestCopyField() {
547547
LoadWithChangedLine(m1_.get(), 7);
548548
LoadWithChangedLine(m2_.get(), 0);
549549

550-
Msg from;
551-
from.add_repeated_msg()->CopyFrom(*m1_);
552-
from.add_repeated_msg()->CopyFrom(*m2_);
553-
554-
Msg to;
555-
to.add_repeated_msg()->CopyFrom(*m1_);
556-
to.add_repeated_msg()->CopyFrom(*m1_);
557-
EXPECT_TRUE(Mutate(from, to));
558-
559-
to.Clear();
560-
to.add_repeated_msg()->CopyFrom(*m2_);
561-
to.add_repeated_msg()->CopyFrom(*m2_);
562-
EXPECT_TRUE(Mutate(from, to));
550+
for (int i = 0; i < 2; ++i, m1_.swap(m2_)) {
551+
Msg from;
552+
from.add_repeated_msg()->CopyFrom(*m1_);
553+
from.add_repeated_msg()->CopyFrom(*m2_);
554+
from.mutable_repeated_msg(1)->add_repeated_string("repeated_string");
555+
556+
Msg to;
557+
to.add_repeated_msg()->CopyFrom(*m1_);
558+
to.add_repeated_msg()->CopyFrom(*m1_);
559+
to.mutable_repeated_msg(1)->add_repeated_string("repeated_string");
560+
EXPECT_TRUE(Mutate(from, to));
561+
}
563562
}
564563

565564
TEST_P(MutatorFieldTest, CopyField) {

0 commit comments

Comments
 (0)