Skip to content

Commit ec3aded

Browse files
committed
Add quick test target (for CI)
1 parent 046501c commit ec3aded

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

test/Jamfile.v2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ test-suite program_options :
4040

4141
exe test_convert : test_convert.cpp ;
4242

43+
# `quick` target (for CI)
44+
run quick.cpp : --path=initial ;

test/quick.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
// Copyright 2017 Peter Dimov.
3+
//
4+
// Distributed under the Boost Software License, Version 1.0.
5+
//
6+
// See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt
8+
9+
// See library home page at http://www.boost.org/libs/program_options
10+
11+
#include <boost/program_options.hpp>
12+
#include <boost/core/lightweight_test.hpp>
13+
14+
namespace po = boost::program_options;
15+
16+
int main( int argc, char const* argv[] )
17+
{
18+
po::options_description desc( "Allowed options" );
19+
20+
desc.add_options()
21+
( "path,p", po::value<std::string>(), "set initial path" )
22+
;
23+
24+
po::variables_map vm;
25+
26+
try
27+
{
28+
po::store( po::parse_command_line( argc, argv, desc ), vm );
29+
po::notify( vm );
30+
}
31+
catch( std::exception const & x )
32+
{
33+
std::cerr << "Error: " << x.what() << std::endl;
34+
return 1;
35+
}
36+
37+
std::string p;
38+
39+
if( vm.count( "path" ) )
40+
{
41+
p = vm[ "path" ].as<std::string>();
42+
}
43+
44+
std::string expected( "initial" );
45+
46+
BOOST_TEST_EQ( p, expected );
47+
48+
return boost::report_errors();
49+
}

0 commit comments

Comments
 (0)