From 62620979c2081177b7d07f8780ee8cd8ba9d3cb9 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 27 Mar 2024 17:10:43 -0700 Subject: [PATCH] Add a test for repeated field orderings demonstrating that MessageDifferencer::Equals and MessageDifferencer::Equivalent treat these cases in the same way. PiperOrigin-RevId: 619712729 --- .../protobuf/util/message_differencer_unittest.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index 58fca75e7a..a77f819518 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -1153,6 +1153,21 @@ TEST(MessageDifferencerTest, BasicFieldOrderingInequalityTest) { EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2)); } +TEST(MessageDifferencerTest, BasicRepeatedFieldOrderingInequalityTest) { + // Create the testing protos + unittest::MoreString msg1; + unittest::MoreString msg2; + + msg1.add_data("a"); + msg1.add_data("b"); + msg2.add_data("b"); + msg2.add_data("a"); + + // Compare + EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2)); + EXPECT_FALSE(util::MessageDifferencer::Equivalent(msg1, msg2)); +} + TEST(MessageDifferencerTest, BasicExtensionTest) { // Create the testing protos unittest::TestAllExtensions msg1;