1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 04:33:53 +00:00
CLI11/tests/SmallTest.cpp
Henry Fredrick Schreiner d070f32ed6 Adding cmake, tests
2017-01-26 16:48:30 -05:00

44 lines
995 B
C++

#include "CLI.hpp"
#include "gtest/gtest.h"
TEST(Split, GoodStrings) {
std::vector<std::string> test_strings = {"a,boo", ",coo", "d,", "Q,this-is", "s", "single"};
std::string s, l;
std::tie(s, l) = CLI::split("a,boo");
EXPECT_EQ("a", s);
EXPECT_EQ("boo", l);
std::tie(s, l) = CLI::split(",coo");
EXPECT_EQ("", s);
EXPECT_EQ("coo", l);
std::tie(s, l) = CLI::split("d,");
EXPECT_EQ("d", s);
EXPECT_EQ("", l);
std::tie(s, l) = CLI::split("Q,this-is");
EXPECT_EQ("Q", s);
EXPECT_EQ("this-is", l);
std::tie(s, l) = CLI::split("s");
EXPECT_EQ("s", s);
EXPECT_EQ("", l);
std::tie(s, l) = CLI::split("single");
EXPECT_EQ("", s);
EXPECT_EQ("single", l);
}
TEST(Split, BadStrings) {
std::vector<std::string> test_fails= {"a,,boo", "a,b,c", "ssd,sfd", "-a", "", ",", "one two"};
for(std::string name : test_fails) {
EXPECT_THROW(CLI::split(name), CLI::BadNameString);
}
}