]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/program_options/test/optional_test.cpp
1 // Distributed under the Boost Software License, Version 1.0.
2 // (See accompanying file LICENSE_1_0.txt
3 // or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include <boost/program_options.hpp>
6 namespace po
= boost::program_options
;
8 #include <boost/optional.hpp>
12 #include "minitest.hpp"
14 std::vector
<std::string
> sv(const char* array
[], unsigned size
)
16 std::vector
<std::string
> r
;
17 for (unsigned i
= 0; i
< size
; ++i
)
18 r
.push_back(array
[i
]);
24 boost::optional
<int> foo
, bar
, baz
;
26 po::options_description desc
;
28 ("foo,f", po::value(&foo
), "")
29 ("bar,b", po::value(&bar
), "")
30 ("baz,z", po::value(&baz
), "")
33 const char* cmdline1_
[] = { "--foo=12", "--bar", "1"};
34 std::vector
<std::string
> cmdline1
= sv(cmdline1_
,
35 sizeof(cmdline1_
)/sizeof(const char*));
37 po::store(po::command_line_parser(cmdline1
).options(desc
).run(), vm
);
41 BOOST_CHECK(*foo
== 12);
44 BOOST_CHECK(*bar
== 1);
49 int main(int, char*[])