From 97ad7e11f6cf441029da147e4a321158d8fd713d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Fri, 15 May 2015 22:12:26 +0200 Subject: [PATCH] Added some Command tests. --- tests/Makefile.am | 22 ++++++++++-- tests/command/src/option_test_command.cpp | 43 +++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tests/command/src/option_test_command.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 214d6f2..f489244 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = subdir-objects -TESTS = \ +TEST_PROGS = \ descriptive_holds_data.test \ callable_invokes_provided_function.test \ callable_invokes_void_function.test \ @@ -25,10 +25,26 @@ TESTS = \ multivalue_should_extract_arguments_by_separator.test \ multivalue_should_extract_options_by_separator.test -noinst_PROGRAMS = $(TESTS) +TEST_SCRPTS = \ + command/understand_void_option.test \ + command/understand_bool_option.test + +TESTS = \ + $(TEST_PROGS) \ + $(TEST_SCRPTS) + +EXTRA_DIST = \ + $(TEST_SCRPTS) + +noinst_PROGRAMS = \ + $(TEST_PROGS) \ + command/option_test_command AM_CXXFLAGS = -I$(top_srcdir)/include -std=c++11 +check-% : %.test all + @srcdir=$(srcdir); export srcdir; + descriptive_holds_data_test_SOURCES = descriptive/holds_data.cpp callable_invokes_provided_function_test_SOURCES = callable/invokes_provided_function.cpp @@ -58,3 +74,5 @@ required_should_be_required_test_SOURCES = required/should_be_required.cpp multivalue_should_extract_arguments_by_separator_test_SOURCES = multiValue/should_extract_arguments_by_separator.cpp multivalue_should_extract_options_by_separator_test_SOURCES = multiValue/should_extract_options_by_separator.cpp + +command_option_test_command_SOURCES = command/src/option_test_command.cpp diff --git a/tests/command/src/option_test_command.cpp b/tests/command/src/option_test_command.cpp new file mode 100644 index 0000000..312d4aa --- /dev/null +++ b/tests/command/src/option_test_command.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "option.h" +#include "command.h" + +using namespace command; + +void option_function(std::string a) { + std::cout << "Help function " << a << std::endl; +} + +int main(int argc, char *argv[]) { + try { + Command command(argc, argv, { + new Option("void", "void Test", [](void) { + std::cout << "VOID" << std::endl; + }), + new Option("char", "char Test", [](char a) { + std::cout << "char: " << a << std::endl; + }), + new Option("bool", "bool Test", [](bool b) { + std::cout << "bool: " << b << std::endl; + }), + new Option("int", "int Test", [](int i) { + std::cout << "int: " << i << std::endl; + }), + new Option("float", "float Test", [](float f) { + std::cout << "float: " << f << std::endl; + }), + new Option("std::string", "std::string Test", [](std::string s) { + std::cout << "std::string: " << s << std::endl; + }) + }); + } + catch(const std::exception & e) { + std::cout << e.what() << std::endl; + return 1; + } + + return 0; +} \ No newline at end of file -- 2.30.2