Add Option tests.
[command.git] / tests / option / should_match_exact_name.cpp
diff --git a/tests/option/should_match_exact_name.cpp b/tests/option/should_match_exact_name.cpp
new file mode 100644 (file)
index 0000000..81f3778
--- /dev/null
@@ -0,0 +1,36 @@
+#include <iostream>
+#include <vector>
+
+#include "option.h"
+
+#define NAME "test"
+
+using namespace std;
+using namespace command;
+
+void function(void) { }
+
+int main() {
+    std::vector<std::string> badOptions;
+    badOptions.push_back("--test");
+    badOptions.push_back("-test");
+    badOptions.push_back("tes");
+    badOptions.push_back("te");
+    badOptions.push_back("t");
+
+    Option<void> option(NAME, "Option should match only exact name", function);
+    for (std::string bad : badOptions) {
+        if (option.understand(bad)) {
+            std::cout << option.describe() << " but '" << NAME << "' was matched as same to '" << bad << "'\n";
+        }
+    }
+
+    if (option.understand(NAME)) {
+        std::cout << option.describe() << " and it understands it correctly\n";
+        return 0;
+    }
+
+    std::cout << option.describe() << " but no name was found\n";
+
+    return 1;
+}