Commit d857b24786f961371830620f71fedd89b63ae8b8

Authored by Henry Fredrick Schreiner
1 parent 6e8d7dc2

Filling out string tools

Showing 1 changed file with 21 additions and 0 deletions
tests/HelpersTest.cpp
@@ -25,6 +25,14 @@ TEST(Split, Empty) { @@ -25,6 +25,14 @@ TEST(Split, Empty) {
25 EXPECT_EQ("", out.at(0)); 25 EXPECT_EQ("", out.at(0));
26 } 26 }
27 27
  28 +TEST(String, InvalidName) {
  29 + EXPECT_TRUE(CLI::detail::valid_name_string("valid"));
  30 + EXPECT_FALSE(CLI::detail::valid_name_string("-invalid"));
  31 + EXPECT_TRUE(CLI::detail::valid_name_string("va-li-d"));
  32 + EXPECT_FALSE(CLI::detail::valid_name_string("vali&d"));
  33 + EXPECT_TRUE(CLI::detail::valid_name_string("_valid"));
  34 +}
  35 +
28 TEST(Trim, Various) { 36 TEST(Trim, Various) {
29 std::string s1{" sdlfkj sdflk sd s "}; 37 std::string s1{" sdlfkj sdflk sd s "};
30 std::string a1{"sdlfkj sdflk sd s"}; 38 std::string a1{"sdlfkj sdflk sd s"};
@@ -289,6 +297,18 @@ TEST(SplitUp, Spaces) { @@ -289,6 +297,18 @@ TEST(SplitUp, Spaces) {
289 EXPECT_EQ(oput, result); 297 EXPECT_EQ(oput, result);
290 } 298 }
291 299
  300 +TEST(SplitUp, BadStrings) {
  301 + std::vector<std::string> oput = {"one", "\" two three"};
  302 + std::string orig {" one \" two three "};
  303 + std::vector<std::string> result = CLI::detail::split_up(orig);
  304 + EXPECT_EQ(oput, result);
  305 +
  306 + oput = {"one", "\' two three"};
  307 + orig = " one \' two three ";
  308 + result = CLI::detail::split_up(orig);
  309 + EXPECT_EQ(oput, result);
  310 +}
  311 +
292 TEST(Types, TypeName) { 312 TEST(Types, TypeName) {
293 std::string int_name = CLI::detail::type_name<int>(); 313 std::string int_name = CLI::detail::type_name<int>();
294 EXPECT_EQ("INT", int_name); 314 EXPECT_EQ("INT", int_name);
@@ -345,3 +365,4 @@ TEST(Types, LexicalCastString) { @@ -345,3 +365,4 @@ TEST(Types, LexicalCastString) {
345 CLI::detail::lexical_cast(input, output); 365 CLI::detail::lexical_cast(input, output);
346 EXPECT_EQ(input, output); 366 EXPECT_EQ(input, output);
347 } 367 }
  368 +