From ec3aded08ecaf8bd3d809b6df4457ed622da0e7e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 2 Dec 2017 18:38:20 +0200 Subject: [PATCH] Add `quick` test target (for CI) --- test/Jamfile.v2 | 2 ++ test/quick.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/quick.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6c866ad..a45ed8e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -40,3 +40,5 @@ test-suite program_options : exe test_convert : test_convert.cpp ; +# `quick` target (for CI) +run quick.cpp : --path=initial ; diff --git a/test/quick.cpp b/test/quick.cpp new file mode 100644 index 0000000..edf45c4 --- /dev/null +++ b/test/quick.cpp @@ -0,0 +1,49 @@ + +// Copyright 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/program_options + +#include +#include + +namespace po = boost::program_options; + +int main( int argc, char const* argv[] ) +{ + po::options_description desc( "Allowed options" ); + + desc.add_options() + ( "path,p", po::value(), "set initial path" ) + ; + + po::variables_map vm; + + try + { + po::store( po::parse_command_line( argc, argv, desc ), vm ); + po::notify( vm ); + } + catch( std::exception const & x ) + { + std::cerr << "Error: " << x.what() << std::endl; + return 1; + } + + std::string p; + + if( vm.count( "path" ) ) + { + p = vm[ "path" ].as(); + } + + std::string expected( "initial" ); + + BOOST_TEST_EQ( p, expected ); + + return boost::report_errors(); +}