0111502e48a1df7e921f46d08625f452f44db159
[command.git] / tests / argument / handles_negative_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 class do not understand negative float values\n";
26         return 1;
27     }
28
29     if (test == std::stof(VALUE)) {
30         cout << "Argument class handles negative float values\n";
31         return 0;
32     }
33
34     cout << "Argument class do not handle negative float values\n";
35
36     return 1;
37 }