Possibility to pass class method reference
[command.git] / tests / option / should_match_exact_name.cpp
1 #include <iostream>
2 #include <vector>
3
4 #include "option.h"
5
6 #define NAME "test"
7
8 using namespace std;
9 using namespace command;
10
11 void _function(void) { }
12
13 int main() {
14     std::vector<std::string> badOptions;
15     badOptions.push_back("--test");
16     badOptions.push_back("-test");
17     badOptions.push_back("tes");
18     badOptions.push_back("te");
19     badOptions.push_back("t");
20
21     Option<void> option(NAME, "Option should match only exact name", _function);
22     for (std::string bad : badOptions) {
23         if (option.understand(bad)) {
24             std::cout << option.describe() << " but '" << NAME << "' was matched as same to '" << bad << "'\n";
25         }
26     }
27
28     if (option.understand(NAME)) {
29         std::cout << option.describe() << " and it understands it correctly\n";
30         return 0;
31     }
32
33     std::cout << option.describe() << " but no name was found\n";
34
35     return 1;
36 }