File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -167,3 +167,11 @@ std::string escape_non_alnum(const std::string &to_escape)
167
167
}
168
168
return escaped.str ();
169
169
}
170
+ std::string capitalize (const std::string &str)
171
+ {
172
+ if (str.empty ())
173
+ return str;
174
+ std::string capitalized = str;
175
+ capitalized[0 ] = toupper (capitalized[0 ]);
176
+ return capitalized;
177
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Author: Daniel Poetzl
18
18
19
19
std::string strip_string (const std::string &s);
20
20
21
+ std::string capitalize (const std::string &str);
22
+
21
23
// / Given a string s, split into a sequence of substrings when separated by
22
24
// / specified delimiter.
23
25
// / \param s: The string to split up
Original file line number Diff line number Diff line change 5
5
#include " string_utils.h"
6
6
#include < algorithm>
7
7
8
- std::string capitalize (const std::string &str)
9
- {
10
- std::string capitalized = str;
11
- capitalized[0 ] = toupper (capitalized[0 ]);
12
- return capitalized;
13
- }
14
-
15
8
labelt::labelt (std::vector<std::string> components)
16
9
{
17
10
auto to_lower_string = [](const std::string &s) -> std::string {
Original file line number Diff line number Diff line change
1
+ // Copyright 2016-2020 Diffblue Limited. All Rights Reserved.
2
+
3
+
4
+ #include < testing-utils/use_catch.h>
5
+ #include < util/string_utils.h>
6
+
7
+ TEST_CASE (" capitalize" , " [core][util][string_utils]" )
8
+ {
9
+ REQUIRE (capitalize (" " ) == " " );
10
+ REQUIRE (capitalize (" abc" ) == " Abc" );
11
+ REQUIRE (capitalize (" aBc" ) == " ABc" );
12
+ REQUIRE (capitalize (" ABc" ) == " ABc" );
13
+ REQUIRE (capitalize (" abc def" ) == " Abc def" );
14
+ REQUIRE (capitalize (" 1" ) == " 1" );
15
+ }
You can’t perform that action at this time.
0 commit comments