X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=tests%2Foption%2Fshould_match_exact_name.cpp;fp=tests%2Foption%2Fshould_match_exact_name.cpp;h=81f3778a25873c5a16e54cbc61b76f4afd2f4a47;hb=f689b4b00fd8853af1026cd09a059c304fb6984d;hp=0000000000000000000000000000000000000000;hpb=ffa13e9b3700e8e3065b5945dab3dc3924c32b00;p=command.git diff --git a/tests/option/should_match_exact_name.cpp b/tests/option/should_match_exact_name.cpp new file mode 100644 index 0000000..81f3778 --- /dev/null +++ b/tests/option/should_match_exact_name.cpp @@ -0,0 +1,36 @@ +#include +#include + +#include "option.h" + +#define NAME "test" + +using namespace std; +using namespace command; + +void function(void) { } + +int main() { + std::vector badOptions; + badOptions.push_back("--test"); + badOptions.push_back("-test"); + badOptions.push_back("tes"); + badOptions.push_back("te"); + badOptions.push_back("t"); + + Option option(NAME, "Option should match only exact name", function); + for (std::string bad : badOptions) { + if (option.understand(bad)) { + std::cout << option.describe() << " but '" << NAME << "' was matched as same to '" << bad << "'\n"; + } + } + + if (option.understand(NAME)) { + std::cout << option.describe() << " and it understands it correctly\n"; + return 0; + } + + std::cout << option.describe() << " but no name was found\n"; + + return 1; +}