mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2026-01-27 10:22:42 +00:00
Add operator<< for TopicPartition
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include <sstream>
|
||||
#include <gtest/gtest.h>
|
||||
#include "cppkafka/topic_partition_list.h"
|
||||
#include "cppkafka/topic_partition.h"
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
using namespace cppkafka;
|
||||
|
||||
class TopicPartitionListTest : public testing::Test {
|
||||
@@ -26,3 +29,20 @@ TEST_F(TopicPartitionListTest, Conversion) {
|
||||
EXPECT_EQ(item1.get_offset(), item2.get_offset());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TopicPartitionListTest, AsString) {
|
||||
ostringstream output;
|
||||
TopicPartition topic_partition("foo", 5);
|
||||
output << topic_partition;
|
||||
EXPECT_EQ("foo[5]", output.str());
|
||||
}
|
||||
|
||||
TEST_F(TopicPartitionListTest, ListAsString) {
|
||||
ostringstream output;
|
||||
TopicPartitionList list;
|
||||
list.push_back("foo");
|
||||
list.push_back({ "bar", 2 });
|
||||
|
||||
output << list;
|
||||
EXPECT_EQ("[ foo[-1], bar[2] ]", output.str());
|
||||
}
|
||||
Reference in New Issue
Block a user