From: Rafał Długołęcki Date: Sat, 9 May 2015 14:14:31 +0000 (+0200) Subject: Add required test for parameter. X-Git-Tag: v0.2~8 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=1db559f7394bb6384c7f9dddc8de3927bcb263c5;p=command.git Add required test for parameter. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 6a0fa06..f338994 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 0000000..fea33c4 --- /dev/null +++ b/tests/parameter/should_be_non_required.cpp @@ -0,0 +1,23 @@ +#include +#include + +#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; +} +