In fact I take back the TestAnyPointer::Builder blob as it looks like 
that's generated code. Can you please help understand how can the two capnp 
objects be compared?

On Thursday, June 2, 2016 at 5:45:06 PM UTC-4, [email protected] 
wrote:
>
> Hi,
>
> I'm currently experimenting with Cap'n Proto and need to write some custom 
> benchmark tests. One of the things I need to do is to ensure the stored and 
> retrieved data is the same. The way I'm doing that currently (for learning 
> the API's mainly) is
>
>
>     ::capnp::MallocMessageBuilder message;
>
>     AddressBook::Builder bookWriter = message.initRoot<AddressBook>();
>
>
>     /* Generic function to add data to the AddressBook */
>
>     writeAddressBook(bookWriter);
>
>
>     /* Write to array buffer*/
>
>     const kj::Array<capnp::word> serializedBuffer = 
> messageToFlatArray(message);
>
>
>     /* Read From array buffer */
>
>     ::capnp::FlatArrayMessageReader reader(serializedBuffer.asPtr());
>
>     AddressBook::Reader bookReader = reader.getRoot<AddressBook>();
>
>
>     if (bookReader == bookWriter) {
>
>         std::cout << "Valid in-memory write-read" << std::endl;
>
>     } else {
>
>         std::cout << "Oops!!!" << std::endl;
>
>     }
>
>
>
> I see some examples in the test.capnp.h where you can get 
> AnyPointer::Builder like so:
>
>
> inline ::capnp::AnyPointer::Builder 
> TestAnyPointer::Builder::getAnyPointerField() {
>
>   return ::capnp::AnyPointer::Builder(
>
>       _builder.getPointerField(0 * ::capnp::POINTERS));
>
> }
>
>
> But I guess I'm having a hard time imagining jumping through hoops like to 
> to compare two capnp objects. Is there a better solution for testing 
> equality of two objects; if so please help with example code.
>
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to