option_handles_boolean_value.test \
option_handles_void_value.test \
option_should_match_exact_name.test \
- option_should_throw_exception_on_missing_value.test
+ option_should_throw_exception_on_missing_value.test \
+ required_should_be_required.test
noinst_PROGRAMS = $(TESTS)
option_handles_void_value_test_SOURCES = option/handles_void_value.cpp
option_should_match_exact_name_test_SOURCES = option/should_match_exact_name.cpp
option_should_throw_exception_on_missing_value_test_SOURCES = option/should_throw_exception_on_missing_value.cpp
+
+required_should_be_required_test_SOURCES = required/should_be_required.cpp
--- /dev/null
+#include <iostream>
+
+#include "required.h"
+#include "argument.h"
+#include "option.h"
+
+using namespace std;
+using namespace command;
+
+#define NAME "test"
+#define VALUE "1"
+
+#define OPTION NAME "=" VALUE
+
+typedef int Type;
+
+void function(Type val) { }
+
+int main() {
+ Parameter * requiredOption = new Required(new Option<Type>(NAME, "Required Option", function));
+ Parameter * requiredArgument = new Required(new Argument<Type>("Required Argument", function));
+
+ if (!requiredOption->isRequired()) {
+ cout << requiredOption->describe() << " should be treated as required but it is not\n";
+ delete requiredOption;
+ return 1;
+ }
+ if (!requiredArgument->isRequired()) {
+ cout << requiredArgument->describe() << " should be treated as required but it is not\n";
+ delete requiredOption;
+ return 1;
+ }
+
+ cout << "Required decorator correctly returns its property\n";
+
+ return 0;
+}