void testBufferedPortToSubscriber() { report(0,"BufferedPort to Subscriber test"); Node n("/node"); BufferedPort<Bottle> pout; pout.setWriteOnly(); pout.open("very_interesting_topic"); { Node n2("/node2"); Subscriber<Bottle> pin("/very_interesting_topic"); pin.read(false); // make sure we are in buffered mode waitForOutput(pout,10); Bottle& b = pout.prepare(); b.clear(); b.addInt(42); pout.write(); pout.waitForWrite(); Bottle *bin = pin.read(); checkTrue(bin!=NULL,"message arrived"); if (!bin) return; checkEqual(bin->get(0).asInt(),42,"message is correct"); } }
void testUnbufferedSubscriber() { report(0,"Unbuffereded Subscriber test"); Node n("/node"); BufferedPort<Bottle> pout; pout.setWriteOnly(); pout.open("very_interesting_topic"); { Node n2("/node2"); Subscriber<Bottle> pin("/very_interesting_topic"); waitForOutput(pout,10); Bottle& b = pout.prepare(); b.clear(); b.addInt(42); pout.write(); Bottle bin; bin.addInt(99); pin.read(bin); pout.waitForWrite(); checkEqual(bin.get(0).asInt(),42,"message is correct"); } }