Commit 371b11b7 authored by Cedric Caffy's avatar Cedric Caffy
Browse files

utils::trimString() now returns an empty string if the string passed in...

utils::trimString() now returns an empty string if the string passed in parameter contains only white-space characters
parent c939f4d5
Pipeline #240 passed with stages
in 14 minutes and 11 seconds
......@@ -9,6 +9,11 @@ This release contains the CTA software Recommended Access Order (RAO) implemente
- CTA software Recommended Access Order (RAO) implemented for LTO drives
- Upgraded EOS to 4.8.20-1
### Bug fixes
- cta/CTA#895 [catalogue] RdbmsCatalogue::deleteLogicalLibrary does not delete empty logical library
- utils::trimString() now returns an empty string if the string passed in parameter contains only white-space characters
# v3.1-7
## Summary
......@@ -17,7 +22,6 @@ This release contains a correction of a performance issue introduced in the v3.1
### Bug fixes
- cta/CTA#895 [catalogue] RdbmsCatalogue::deleteLogicalLibrary does not delete empty logical library
- cta/CTA#893 Corrected slowliness of RdbmsCatalogue::getArchiveFileToRetrieveByArchiveFileId()
# v3.1-6
......
......@@ -814,6 +814,21 @@ TEST_F(cta_UtilsTest, testTrimStringContainingLeftAndRightWhiteSpace) {
ASSERT_EQ(std::string("VALUE"), trimmedString);
}
TEST_F(cta_UtilsTest, testTrimStringContainingOnlySpace) {
using namespace cta;
const std::string s(" ");
const std::string trimmedString = utils::trimString(s);
ASSERT_EQ(std::string(""), trimmedString);
}
TEST_F(cta_UtilsTest, testTrimStringOneCharacter) {
using namespace cta;
const std::string s(" a ");
const std::string trimmedString = utils::trimString(s);
ASSERT_EQ(1,trimmedString.size());
ASSERT_EQ(std::string("a"), trimmedString);
}
TEST_F(cta_UtilsTest, testCopyStringNullDst) {
using namespace cta;
char dummy[6] = "Dummy";
......
......@@ -285,9 +285,12 @@ std::string trimString(const std::string &s) {
std::string::const_iterator it2;
size_t endpos = s.find_last_not_of(spaces);
if (std::string::npos != endpos) {
//http://www.cplusplus.com/reference/string/string/string/
//The string constructor with iterator does not include the character pointed by the end iterator
it2 = endpos + 1 + s.begin();
} else {
it2 = s.end();
//The string contains only white characters, the trimmed string should be an empty string
it2 = s.begin();
}
return std::string(it1, it2);
......
......@@ -492,6 +492,9 @@ Currently contains a helper for the client-ar script, which should be installed
%changelog
* Fri Sep 25 2020 julien.leduc (at) cern.ch - 3.1-8
- CTA software Recommended Access Order (RAO) implemented for LTO drives
- Upstream EOS 4.8.20-1
- utils::trimString() now returns an empty string if the string passed in parameter contains only white-space characters
- cta/CTA#895 [catalogue] RdbmsCatalogue::deleteLogicalLibrary does not delete empty logical library
* Wed Sep 23 2020 julien.leduc (at) cern.ch - 3.1-7
- cta/CTA#893 Corrected slowliness of RdbmsCatalogue::getArchiveFileToRetrieveByArchiveFileId()
* Mon Sep 21 2020 julien.leduc (at) cern.ch - 3.1-6
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment