On Mon, Apr 4, 2011 at 00:26, des fitzgerald
<[email protected]> wrote:
> Hi, below is more orless the same example in the on-line documentation
>
> "the message Foo" example turned into a cppunit_test
>
> I thought the DebugString method would always work, based upon what I
> have read.
> This crashes? any guidance?
Where does it crash (stacktrace?). What compiler are you using ?
> thanks
> des
>
> static std::string data; // Will store a serialized version of the
> message.
> void ProtocolsTestCase::testExerciseParsing() {
> testCreateSerializedMessage();
>
> // parse from string
> testParseFromString();
>
> //
> // testDynamicParseFromString();
> }
> // get on top of dynamic creation of a protobuf message
> void ProtocolsTestCase::testCreateSerializedMessage() {
> // Create a message and serialize it.
> Foo foo;
> foo.set_text("Hello World!");
> foo.add_numbers(1);
> foo.add_numbers(5);
> foo.add_numbers(42);
>
> foo.SerializeToString(&data);
> }
> void ProtocolsTestCase::testParseFromString() {
> // Parse the serialized message and check that it contains the
> correct data.
> Foo foo;
> foo.ParseFromString(data);
>
> CPPUNIT_ASSERT(foo.text() == "Hello World!");
> CPPUNIT_ASSERT(foo.numbers_size() == 3);
> CPPUNIT_ASSERT(foo.numbers(0) == 1);
> CPPUNIT_ASSERT(foo.numbers(1) == 5);
> CPPUNIT_ASSERT(foo.numbers(2) == 42);
> std::string out = foo.DebugString();
> lprintf("%s\n", out.c_str());
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.