Skip to content

Commit

Permalink
#509: Add Properties equal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Nov 10, 2023
1 parent ef6f343 commit 9930ecb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/utils/gtest/src/CxxPropertiesTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ TEST_F(CxxPropertiesTestSuite, StoreAndLoadTest) {
std::string path{"cxx_store_and_load_test.properties"};

celix::Properties props{};
props.set("key1", 1);
props.set("key2", 2);
props.set("key1", "1");
props.set("key2", "2");

EXPECT_NO_THROW(props.store(path));

celix::Properties loadedProps{};
EXPECT_NO_THROW(loadedProps = celix::Properties::load(path));
EXPECT_EQ(props.size(), loadedProps.size());
EXPECT_TRUE(loadedProps == props);

try {
loadedProps = celix::Properties::load("non-existence");
Expand Down
9 changes: 9 additions & 0 deletions libs/utils/include/celix/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ namespace celix {
return ValueRef{cProps, std::move(key)};
}

/**
* @brief Compare two properties objects for equality.
* @param rhs
* @return true if the properties are equal, false otherwise.
*/
bool operator==(const Properties& rhs) const {
return celix_properties_equals(cProps.get(), rhs.cProps.get());
}

/**
* @brief begin iterator
*/
Expand Down

0 comments on commit 9930ecb

Please sign in to comment.