Beispiel #1
0
TEST(table, convert_to_rabbitmq) {
  Table table_in;
  table_in.insert(TableEntry("void_key", TableValue()));
  table_in.insert(TableEntry("bool_key", true));
  table_in.insert(TableEntry("int8_key", int8_t(8)));
  table_in.insert(TableEntry("int16_key", int16_t(16)));
  table_in.insert(TableEntry("int32_key", int32_t(32)));
  table_in.insert(TableEntry("int64_key", int64_t(64)));
  table_in.insert(TableEntry("float_key", float(1.5)));
  table_in.insert(TableEntry("double_key", double(2.25)));
  table_in.insert(TableEntry("string_key", "A string!"));

  std::vector<TableValue> array_in;
  array_in.push_back(TableValue(false));
  array_in.push_back(TableValue(int32_t(10)));
  array_in.push_back(TableValue(std::string("Another string")));

  table_in.insert(TableEntry("array_key", array_in));

  Table table_inner;
  table_inner.insert(TableEntry("inner_string", "An inner table"));
  table_inner.insert(TableEntry("inner array", array_in));

  table_in.insert(TableEntry("table_key", table_inner));

  BasicMessage::ptr_t message = BasicMessage::Create();
  message->HeaderTable(table_in);

  EXPECT_TRUE(message->HeaderTableIsSet());
  Table table_out = message->HeaderTable();
  EXPECT_EQ(table_in.size(), table_out.size());
  EXPECT_TRUE(std::equal(table_in.begin(), table_in.end(), table_out.begin()));
}
Beispiel #2
0
TEST(table, convert_to_rabbitmq_empty) {
  Table table_in;

  BasicMessage::ptr_t message = BasicMessage::Create();
  message->HeaderTable(table_in);

  Table table_out = message->HeaderTable();
  EXPECT_EQ(0, table_out.size());
}