option_handles_float_value.test \
option_handles_negative_float_value.test \
option_handles_boolean_value.test \
- option_handles_void_value.test
+ option_handles_void_value.test \
+ option_should_match_exact_name.test
noinst_PROGRAMS = $(TESTS)
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
+option_should_match_exact_name_test_SOURCES = option/should_match_exact_name.cpp
--- /dev/null
+#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;
+}