24 #include "goby/acomms/dccl.h" 27 using goby::acomms::operator<<;
29 int main(
int argc,
char* argv[])
37 codec->validate(short_id_msg.GetDescriptor());
38 codec->info(short_id_msg.GetDescriptor(), &
goby::glog);
41 assert(codec->size(short_id_msg) == 1);
42 codec->encode(&encoded, short_id_msg);
43 codec->decode(encoded, &short_id_msg);
46 codec->validate(long_id_msg.GetDescriptor());
47 codec->info(long_id_msg.GetDescriptor(), &
goby::glog);
48 assert(codec->size(long_id_msg) == 2);
49 codec->encode(&encoded, long_id_msg);
50 codec->decode(encoded, &long_id_msg);
53 codec->validate(short_id_edge_msg.GetDescriptor());
54 codec->info(short_id_edge_msg.GetDescriptor(), &
goby::glog);
55 assert(codec->size(short_id_edge_msg) == 1);
56 codec->encode(&encoded, short_id_edge_msg);
57 codec->decode(encoded, &short_id_edge_msg);
60 codec->validate(long_id_edge_msg.GetDescriptor());
61 codec->info(long_id_edge_msg.GetDescriptor(), &
goby::glog);
62 codec->encode(&encoded, long_id_edge_msg);
63 codec->decode(encoded, &long_id_edge_msg);
64 assert(codec->size(long_id_edge_msg) == 2);
70 codec->validate(too_long_id_msg.GetDescriptor());
73 catch (goby::acomms::DCCLException& e)
78 codec->validate(short_id_msg_with_data.GetDescriptor());
79 codec->info(short_id_msg_with_data.GetDescriptor(), &
goby::glog);
81 short_id_msg_with_data.set_in_head(42);
82 short_id_msg_with_data.set_in_body(37);
83 codec->encode(&encoded, short_id_msg_with_data);
84 codec->decode(encoded, &short_id_msg_with_data);
86 std::cout <<
"all tests passed" << std::endl;
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
static DCCLCodec * get()
DCCLCodec is a singleton class; use this to get a pointer to the class.
common::FlexOstream glog
Access the Goby logger through this object.
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=0)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity...