argument_handles_negative_float_value.test \
argument_handles_boolean_value.test \
option_handles_string_value.test \
+ option_handles_int_value.test \
+ option_handles_negative_int_value.test \
+ option_handles_float_value.test \
+ option_handles_negative_float_value.test \
option_handles_boolean_value.test \
- option_handles_float_value.test
+ option_handles_void_value.test
noinst_PROGRAMS = $(TESTS)
argument_handles_boolean_value_test_SOURCES = argument/handles_boolean_value.cpp
option_handles_string_value_test_SOURCES = option/handles_string_value.cpp
-option_handles_boolean_value_test_SOURCES = option/handles_boolean_value.cpp
+option_handles_int_value_test_SOURCES = option/handles_int_value.cpp
+option_handles_negative_int_value_test_SOURCES = option/handles_negative_int_value.cpp
option_handles_float_value_test_SOURCES = option/handles_float_value.cpp
+option_handles_negative_float_value_test_SOURCES = option/handles_negative_float_value.cpp
+option_handles_boolean_value_test_SOURCES = option/handles_boolean_value.cpp
+option_handles_void_value_test_SOURCES = option/handles_void_value.cpp
}
int main() {
- Argument<ArgumentType> argument("Argument as float", function);
+ Argument<ArgumentType> argument("Argument as negative float", function);
if (argument.understand(VALUE)) {
argument.handle();
}
else {
- cout << "Argument class do not understand negative float values\n";
+ cout << argument.describe() << " do not understand " << VALUE " value\n";
return 1;
}
if (test == std::stof(VALUE)) {
- cout << "Argument class handles negative float values\n";
+ cout << argument.describe() << " handles negative float values\n";
return 0;
}
- cout << "Argument class do not handle negative float values\n";
+ cout << argument.describe() << " do not handle negative float values\n";
return 1;
}
--- /dev/null
+#include <cstring>
+#include <iostream>
+
+#include "option.h"
+
+using namespace std;
+using namespace command;
+
+#define NAME "test"
+#define VALUE "1234567890"
+
+#define OPTION NAME "=" VALUE
+
+typedef int OptionType;
+
+OptionType test;
+
+void function(OptionType value) {
+ test = value;
+}
+
+int main() {
+ Option<OptionType> option(NAME, "Option as int", function);
+
+ if (option.understand(OPTION)) {
+ option.handle();
+ }
+ else {
+ cout << option.describe() << " do not understand int values\n";
+ return 1;
+ }
+
+ if (test == std::stoi(VALUE)) {
+ cout << option.describe() << " handles int values\n";
+ return 0;
+ }
+
+ cout << option.describe() << " do not handle int values\n";
+
+ return 1;
+}
--- /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 negative 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 negative float values\n";
+
+ return 1;
+}
--- /dev/null
+#include <iostream>
+#include <string>
+
+#include "option.h"
+
+using namespace std;
+using namespace command;
+
+#define NAME "test"
+#define VALUE "-1234567890"
+
+#define OPTION NAME "=" VALUE
+
+typedef int OptionType;
+
+OptionType test;
+
+void function(OptionType value) {
+ test = value;
+}
+
+int main() {
+ Option<OptionType> option(NAME, "Option as negative int", function);
+
+ if (option.understand(OPTION)) {
+ option.handle();
+ }
+ else {
+ cout << option.describe() << " do not understand " << VALUE << " value\n";
+ return 1;
+ }
+
+ if (test == std::stoi(VALUE)) {
+ cout << option.describe() << " handles negative int values\n";
+ return 0;
+ }
+
+ cout << option.describe() << " do not handle negative int values\n";
+
+ return 1;
+}
--- /dev/null
+#include <iostream>
+
+#include "option.h"
+
+using namespace std;
+using namespace command;
+
+#define NAME "test"
+
+typedef void OptionType;
+
+bool test = false;
+
+void function() {
+ test = true;
+}
+
+int main() {
+ Option<OptionType> option(NAME, "Option with void value", function);
+
+ if (option.understand(NAME)) {
+ option.handle();
+ }
+ else {
+ cout << option.describe() << " do not understand void values\n";
+ return 1;
+ }
+
+ if (test) {
+ cout << option.describe() << " handles void values\n";
+ return 0;
+ }
+
+ cout << option.describe() << " do not handle void values\n" << endl;
+
+ return 1;
+}