Skip to content

Commit 64ea3eb

Browse files
committed
More tests.
1 parent 0a4f3da commit 64ea3eb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/common/common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ namespace xgboost::common {
7979
if (str.empty()) {
8080
return str;
8181
}
82-
8382
auto first = str.find_first_not_of(" \t\n\r");
8483
if (first == std::string_view::npos) {
8584
return {};

tests/cpp/common/test_common.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ TEST(Common, Trim) {
4444
auto res = TrimLast(" foo ");
4545
ASSERT_EQ(res, std::string_view{" foo"});
4646
}
47+
{
48+
auto res = TrimLast(" ");
49+
ASSERT_EQ(res, std::string_view{});
50+
}
51+
{
52+
auto res = TrimFirst(" ");
53+
ASSERT_EQ(res, std::string_view{});
54+
}
55+
{
56+
auto res = TrimFirst("");
57+
ASSERT_EQ(res, std::string_view{});
58+
}
4759
}
4860

4961
TEST(Common, Split) {

0 commit comments

Comments
 (0)