1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 04:33:53 +00:00
CLI11/try1.cpp
2017-01-25 17:28:39 -05:00

33 lines
845 B
C++

#include "CLI.hpp"
int main (int argc, char** argv) {
std::vector<std::string> test_strings = {"a,boo", ",coo", "d,", "Q,this-is", "s", "single"};
for(std::string name : test_strings) {
std::string one;
std::string two;
std::tie(one, two) = CLI::split(name);
std::cout << one << ", " << two << std::endl;
}
std::vector<std::string> test_fails= {"a,,boo", "a,b,c", "ssd,sfd", "-a", "", ",", "one two"};
for(std::string name : test_fails) {
std::string one;
std::string two;
try {
std::tie(one, two) = CLI::split(name);
std::cout << "Failed to catch: " << name << std::endl;
return 1;
} catch (const CLI::BadNameString &e) {
std::cout << "Hooray! Caught: " << name << std::endl;
}
}
}