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