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