Skip to content

Commit

Permalink
add id initializer list test (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
copperlight authored Dec 8, 2023
1 parent 6c63182 commit e37bd61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)

project(spectator)
project(spectator-cpp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
Expand Down
3 changes: 1 addition & 2 deletions spectator/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class Tags {
public:
Tags() = default;

Tags(
std::initializer_list<std::pair<absl::string_view, absl::string_view>> vs) {
Tags(std::initializer_list<std::pair<absl::string_view, absl::string_view>> vs) {
for (auto& pair : vs) {
add(pair.first, pair.second);
}
Expand Down
6 changes: 6 additions & 0 deletions spectator/id_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ using spectator::Tags;
TEST(Id, Create) {
Id id{"foo", Tags{}};
EXPECT_EQ(id.Name(), "foo");
EXPECT_EQ(id.GetTags().size(), 0);

Id id_tags{"name", Tags{{"k", "v"}, {"k1", "v1"}}};
EXPECT_EQ(id_tags.Name(), "name");
EXPECT_EQ(id_tags.GetTags().size(), 2);

std::shared_ptr<Id> id_of{Id::of("name", Tags{{"k", "v"}, {"k1", "v1"}})};
EXPECT_EQ(id_of->Name(), "name");
EXPECT_EQ(id_of->GetTags().size(), 2);
}

TEST(Id, Tags) {
Expand Down

0 comments on commit e37bd61

Please sign in to comment.