Possibility to pass class method reference
[command.git] / tests / argument / handles_boolean_value.cpp
1 #include <iostream>
2
3 #include "argument.h"
4
5 using namespace std;
6 using namespace command;
7
8 #define FALSE "0"
9 #define TRUE "1"
10
11 typedef bool 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 boolean", _function);
21
22     if (argument.understand(FALSE)) {
23         argument.handle();
24     }
25     else {
26         cout << "Argument class do not understand boolean (FALSE) values\n";
27         return 1;
28     }
29
30     if (test == (bool)std::stoi(FALSE)) {
31         cout << "Argument class handles boolean (FALSE) values\n";
32     }
33
34     Argument<ArgumentType> argument2("Argument as boolean", _function);
35     if (argument2.understand(TRUE)) {
36         argument2.handle();
37     }
38     else {
39         cout << "Argument class do not understand boolean (TRUE) values\n";
40         return 1;
41     }
42
43     if (test == (bool)std::stoi(TRUE)) {
44         cout << "Argument class handles boolean (TRUE) values\n";
45         return 0;
46     }
47
48     cout << "Argument class do not handle boolean values\n";
49
50     return 1;
51 }