From 1db559f7394bb6384c7f9dddc8de3927bcb263c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Sat, 9 May 2015 16:14:31 +0200 Subject: [PATCH] Add required test for parameter. --- tests/Makefile.am | 2 ++ tests/parameter/should_be_non_required.cpp | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/parameter/should_be_non_required.cpp 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; +} + -- 2.30.2