argument_handles_negative_float_value.test \
argument_handles_boolean_value.test \
option_handles_string_value.test \
- option_handles_boolean_value.test
+ option_handles_boolean_value.test \
+ option_handles_float_value.test
noinst_PROGRAMS = $(TESTS)
option_handles_string_value_test_SOURCES = option/handles_string_value.cpp
option_handles_boolean_value_test_SOURCES = option/handles_boolean_value.cpp
+option_handles_float_value_test_SOURCES = option/handles_float_value.cpp
argument.handle();
}
else {
- cout << "Argument class do not understand float values\n";
+ cout << argument.describe() << " do not understand float values\n";
return 1;
}
if (test == std::stof(VALUE)) {
- cout << "Argument class handles float values\n";
+ cout << argument.describe() << " handles float values\n";
return 0;
}
--- /dev/null
+#include <cstring>
+#include <iostream>
+
+#include "option.h"
+
+using namespace std;
+using namespace command;
+
+#define NAME "test"
+#define VALUE "567890.1234"
+
+#define OPTION NAME"="VALUE
+
+typedef float OptionType;
+
+OptionType test;
+
+void function(OptionType value) {
+ test = value;
+}
+
+int main() {
+ Option<OptionType> option(NAME, "Option with float value", function);
+
+ if (option.understand(OPTION)) {
+ option.handle();
+ }
+ else {
+ cout << option.describe() << " do not understand " << VALUE << " value\n";
+ return 1;
+ }
+
+ if (test == std::stof(VALUE)) {
+ cout << option.describe() << " handles " << VALUE << " value\n";
+ return 0;
+ }
+
+ cout << "Option class do not handle float values\n";
+
+ return 1;
+}
option.handle();
}
else {
- cout << "Option class do not understand string values\n";
+ cout << option.describe() << " do not understand string values\n";
return 1;
}
int cmp = strcmp(test.c_str(), VALUE);
if (cmp == 0) {
- cout << "Option class handles string values\n";
+ cout << option.describe() << " handles string values\n";
return 0;
}