Possibility to pass class method reference
[command.git] / tests / argument / handles_string_value.cpp
1 #include <cstring>
2 #include <iostream>
3
4 #include "argument.h"
5
6 using namespace std;
7 using namespace command;
8
9 #define VALUE "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
10
11 typedef std::string ArgumentType;
12
13 ArgumentType test;
14
15 void _function(ArgumentType value) {
16     test = value;
17 }
18
19 int main() {
20     Argument<ArgumentType> argument("Argument as string", _function);
21
22     if (argument.understand(VALUE)) {
23         argument.handle();
24     }
25     else {
26         cout << "Argument class do not understand string values\n";
27         return 1;
28     }
29
30     int cmp = strcmp(test.c_str(), VALUE);
31
32     if (cmp == 0) {
33         cout << "Argument class handles string values\n";
34         return 0;
35     }
36
37     cout << "Argument class do not handle string values\n";
38
39     return 1;
40 }