descriptive_holds_data.test \
callable_invokes_provided_function.test \
parameter_is_descriptive.test \
- argument_handles_string_value.test
+ argument_handles_string_value.test \
+ argument_handles_int_value.test \
+ argument_handles_negative_int_value.test \
+ argument_handles_float_value.test \
+ argument_handles_negative_float_value.test
noinst_PROGRAMS = $(TESTS)
AM_CXXFLAGS = -O3 -I$(top_srcdir)/include -std=c++11
descriptive_holds_data_test_SOURCES = descriptive/holds_data.cpp
+
callable_invokes_provided_function_test_SOURCES = callable/invokes_provided_function.cpp
+
parameter_is_descriptive_test_SOURCES = parameter/is_descriptive.cpp
+
argument_handles_string_value_test_SOURCES = argument/handles_string_value.cpp
+argument_handles_int_value_test_SOURCES = argument/handles_int_value.cpp
+argument_handles_negative_int_value_test_SOURCES = argument/handles_negative_int_value.cpp
+argument_handles_float_value_test_SOURCES = argument/handles_float_value.cpp
+argument_handles_negative_float_value_test_SOURCES = argument/handles_negative_float_value.cpp
--- /dev/null
+#include <iostream>
+
+#include "argument.h"
+
+using namespace std;
+using namespace command;
+
+#define VALUE "567890.1234"
+
+typedef float ArgumentType;
+
+ArgumentType test;
+
+void function(ArgumentType value) {
+ test = value;
+}
+
+int main() {
+ Argument<ArgumentType> argument("Argument as float", function);
+
+ if (argument.understand(VALUE)) {
+ argument.handle();
+ }
+
+ if (test == std::stof(VALUE)) {
+ cout << "Argument class handles float values\n";
+ return 0;
+ }
+
+ cout << "Argument class do not handle float values\n";
+
+
+ return 1;
+}
--- /dev/null
+#include <cstring>
+#include <iostream>
+
+#include "argument.h"
+
+using namespace std;
+using namespace command;
+
+#define VALUE "1234567890"
+
+typedef int ArgumentType;
+
+ArgumentType test;
+
+void function(ArgumentType value) {
+ test = value;
+}
+
+int main() {
+ Argument<ArgumentType> argument("Argument as int", function);
+
+ if (argument.understand(VALUE)) {
+ argument.handle();
+ }
+
+ if (test == std::stoi(VALUE)) {
+ cout << "Argument class handles int values\n";
+ return 0;
+ }
+
+ cout << "Argument class do not handle int values\n";
+
+ return 1;
+}
--- /dev/null
+#include <iostream>
+
+#include "argument.h"
+
+using namespace std;
+using namespace command;
+
+#define VALUE "-567890.1234"
+
+typedef float ArgumentType;
+
+ArgumentType test;
+
+void function(ArgumentType value) {
+ test = value;
+}
+
+int main() {
+ Argument<ArgumentType> argument("Argument as float", function);
+
+ if (argument.understand(VALUE)) {
+ argument.handle();
+ }
+
+ if (test == std::stof(VALUE)) {
+ cout << "Argument class handles negative float values\n";
+ return 0;
+ }
+
+ cout << "Argument class do not handle negative float values\n";
+
+
+ return 1;
+}
--- /dev/null
+#include <iostream>
+
+#include "argument.h"
+
+using namespace std;
+using namespace command;
+
+#define VALUE "-1234567890"
+
+typedef int ArgumentType;
+
+ArgumentType test;
+
+void function(ArgumentType value) {
+ test = value;
+}
+
+int main() {
+ Argument<ArgumentType> argument("Argument as negative int", function);
+
+ if (argument.understand(VALUE)) {
+ argument.handle();
+ }
+
+ if (test == std::stoi(VALUE)) {
+ cout << "Argument class handles negative int values\n";
+ return 0;
+ }
+
+ cout << "Argument class do not handle negative int values\n";
+
+ return 1;
+}
--- /dev/null
+#include <cstring>
+#include <iostream>
+
+#include "argument.h"
+
+using namespace std;
+using namespace command;
+
+#define VALUE "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+
+typedef std::string ArgumentType;
+
+ArgumentType test;
+
+void function(ArgumentType value) {
+ test = value;
+}
+
+int main() {
+ Argument<ArgumentType> argument("Argument as string", function);
+
+ if (argument.understand(VALUE)) {
+ argument.handle();
+ }
+
+ int cmp = strcmp(test.c_str(), VALUE);
+
+ if (cmp == 0) {
+ cout << "Argument class handles string values\n";
+ return 0;
+ }
+
+ cout << "Argument class do not handle string values\n";
+
+ return 1;
+}