Skip to content

Commit

Permalink
MinMaxString: Add *operator for assigning std::MinMaxString
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Klausmann <[email protected]>
  • Loading branch information
tobijk2 committed Sep 21, 2023
1 parent 4716bcb commit 0bcdbaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/libaas/basyx/base/minMaxString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ MinMaxString &MinMaxString::operator=(const MinMaxString &str) noexcept {
return *this;
}

std::string MinMaxString::operator*() noexcept {
return this->str();

}

MinMaxString &MinMaxString::operator=(const basyx::util::string_view& str) noexcept {
replace(str.to_string());
return *this;
Expand Down
1 change: 1 addition & 0 deletions src/libaas/basyx/base/minMaxString.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MinMaxString: protected std::string {
MinMaxString& operator=(const MinMaxString& str) noexcept;
MinMaxString& operator=(const basyx::util::string_view& str) noexcept;
MinMaxString& operator=(const std::string& str) noexcept;
std::string operator*() noexcept;
//MinMaxString& operator=(MinMaxString &) noexcept = default;

bool operator==(const std::string& rhs) {
Expand Down
6 changes: 5 additions & 1 deletion tests/tests_libaas/test_basyx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST_F(BaseTest, MinMaxString) {
ASSERT_EQ(min, mmStr.length());
std::string cmp;
cmp+= base::STRING_PADDING;
ASSERT_STREQ(cmp.data(), mmStr.str().data());
ASSERT_STREQ(cmp.data(), (*mmStr).data());

// Check if max size is honored
base::MinMaxString mmStr2(min, max);
Expand All @@ -77,6 +77,10 @@ TEST_F(BaseTest, MinMaxString) {
mmStr5.assign(ste);
ASSERT_STREQ(ste.data(), mmStr5.str().data());


base::MinMaxString mmStr6(min, max);
mmStr6.assign("bla");
std::string base = *mmStr6;
}

TEST_F(BaseTest, VersionRevisionType)
Expand Down

0 comments on commit 0bcdbaf

Please sign in to comment.