Add required test for parameter.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sat, 9 May 2015 14:14:31 +0000 (16:14 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sat, 9 May 2015 14:14:31 +0000 (16:14 +0200)
tests/Makefile.am
tests/parameter/should_be_non_required.cpp [new file with mode: 0644]

index 6a0fa06e817a8d3e019ca9bb6d09de7217ad2c7c..f338994ea03a2cccde4a1681f7edd8d0ce576c2b 100644 (file)
@@ -5,6 +5,7 @@ TESTS = \
        callable_invokes_provided_function.test \
        callable_invokes_void_function.test \
        parameter_is_descriptive.test \
+       parameter_should_be_non_required.test \
        argument_handles_string_value.test \
        argument_handles_int_value.test \
        argument_handles_negative_int_value.test \
@@ -32,6 +33,7 @@ callable_invokes_provided_function_test_SOURCES  = callable/invokes_provided_fun
 callable_invokes_void_function_test_SOURCES  = callable/invokes_void_function.cpp
 
 parameter_is_descriptive_test_SOURCES  = parameter/is_descriptive.cpp
+parameter_should_be_non_required_test_SOURCES = parameter/should_be_non_required.cpp
 
 argument_handles_string_value_test_SOURCES  = argument/handles_string_value.cpp
 argument_handles_int_value_test_SOURCES  = argument/handles_int_value.cpp
diff --git a/tests/parameter/should_be_non_required.cpp b/tests/parameter/should_be_non_required.cpp
new file mode 100644 (file)
index 0000000..fea33c4
--- /dev/null
@@ -0,0 +1,23 @@
+#include <cstring>
+#include <iostream>
+
+#include "TestParameter.h"
+
+using namespace std;
+using namespace command;
+
+#define DESC "Simple parameter"
+
+int main() {
+    TestParameter parameter(DESC);
+
+    if (parameter.isRequired()) {
+        cout << parameter.describe() << " is required, but it should not\n";
+        return 1;
+    }
+
+    cout << parameter.describe() << " is not required by default\n";
+
+    return 0;
+}
+