Added Argument tests.
[command.git] / tests / argument / handles_string_value.cpp
diff --git a/tests/argument/handles_string_value.cpp b/tests/argument/handles_string_value.cpp
new file mode 100644 (file)
index 0000000..9dd6efa
--- /dev/null
@@ -0,0 +1,36 @@
+#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;
+}