From 4de8f55113007fdc8e34107950e605fc0209d465 Mon Sep 17 00:00:00 2001 From: "jieluo@google.com" Date: Fri, 18 Jul 2014 00:47:59 +0000 Subject: down integrate to svn --- src/google/protobuf/test_util.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/google/protobuf/test_util.h') diff --git a/src/google/protobuf/test_util.h b/src/google/protobuf/test_util.h index 45519573..6e2d552a 100644 --- a/src/google/protobuf/test_util.h +++ b/src/google/protobuf/test_util.h @@ -54,11 +54,15 @@ class TestUtil { static void AddRepeatedFields1(unittest::TestAllTypes* message); static void AddRepeatedFields2(unittest::TestAllTypes* message); static void SetDefaultFields(unittest::TestAllTypes* message); + static void SetOneofFields(unittest::TestAllTypes* message); static void SetAllExtensions(unittest::TestAllExtensions* message); + static void SetOneofFields(unittest::TestAllExtensions* message); static void SetAllFieldsAndExtensions(unittest::TestFieldOrderings* message); static void SetPackedFields(unittest::TestPackedTypes* message); static void SetPackedExtensions(unittest::TestPackedExtensions* message); static void SetUnpackedFields(unittest::TestUnpackedTypes* message); + static void SetOneof1(unittest::TestOneof2* message); + static void SetOneof2(unittest::TestOneof2* message); // Use the repeated versions of the set_*() accessors to modify all the // repeated fields of the messsage (which should already have been @@ -79,6 +83,10 @@ class TestUtil { const unittest::TestPackedExtensions& message); static void ExpectUnpackedFieldsSet( const unittest::TestUnpackedTypes& message); + static void ExpectUnpackedExtensionsSet( + const unittest::TestUnpackedExtensions& message); + static void ExpectOneofSet1(const unittest::TestOneof2& message); + static void ExpectOneofSet2(const unittest::TestOneof2& message); // Expect that the message is modified as would be expected from // Modify*Fields(). @@ -97,6 +105,7 @@ class TestUtil { static void ExpectPackedClear(const unittest::TestPackedTypes& message); static void ExpectPackedExtensionsClear( const unittest::TestPackedExtensions& message); + static void ExpectOneofClear(const unittest::TestOneof2& message); // Check that the passed-in serialization is the canonical serialization we // expect for a TestFieldOrderings message filled in by @@ -119,6 +128,9 @@ class TestUtil { static void ExpectRepeatedExtensionsSwapped( const unittest::TestAllExtensions& message); + static void ExpectAtMostOneFieldSetInOneof( + const unittest::TestOneof2 &message); + // Like above, but use the reflection interface. class ReflectionTester { public: @@ -143,6 +155,11 @@ class TestUtil { void ReleaseLastRepeatedsViaReflection( Message* message, bool expect_extensions_notnull); void SwapRepeatedsViaReflection(Message* message); + void SetAllocatedOptionalMessageFieldsToNullViaReflection( + Message* message); + static void SetAllocatedOptionalMessageFieldsToMessageViaReflection( + Message* from_message, + Message* to_message); enum MessageReleaseState { IS_NULL, @@ -152,6 +169,11 @@ class TestUtil { void ExpectMessagesReleasedViaReflection( Message* message, MessageReleaseState expected_release_state); + // Set and check functions for TestOneof2 messages. No need to construct + // the ReflectionTester by TestAllTypes nor TestAllExtensions. + static void SetOneofViaReflection(Message* message); + static void ExpectOneofSetViaReflection(const Message& message); + private: const FieldDescriptor* F(const string& name); -- cgit v1.2.3