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