mirror of
https://github.com/boostorg/program_options.git
synced 2026-01-20 04:42:24 +00:00
Compare commits
36 Commits
boost-1.35
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b9118089f | ||
|
|
8329c28a1a | ||
|
|
73cf706164 | ||
|
|
e51a3ae742 | ||
|
|
a0a661e4ec | ||
|
|
c25408f6d2 | ||
|
|
63fca63679 | ||
|
|
8c39e5aa8d | ||
|
|
d0aa5abee5 | ||
|
|
90dc6b94d0 | ||
|
|
2320c07267 | ||
|
|
cd647f785a | ||
|
|
4223d3231d | ||
|
|
d1d5636365 | ||
|
|
c00c4a57db | ||
|
|
8ad16ee97c | ||
|
|
0c3e43f2ce | ||
|
|
e42f028278 | ||
|
|
a29728e679 | ||
|
|
232894cb3d | ||
|
|
d39f2b5979 | ||
|
|
8c68a478c9 | ||
|
|
5d1345c5a9 | ||
|
|
a560d767fb | ||
|
|
8c1982de82 | ||
|
|
928d7806f7 | ||
|
|
b99ae04040 | ||
|
|
dc334deea7 | ||
|
|
de66d37405 | ||
|
|
a4375600a2 | ||
|
|
bec34dd1b9 | ||
|
|
7b73b2e84c | ||
|
|
2625de2dd0 | ||
|
|
ac6de20f85 | ||
|
|
3765e8e8e9 | ||
|
|
026c527d8d |
@@ -17,4 +17,12 @@ lib boost_program_options
|
||||
<link>shared:<define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1 # tell source we're building dll's
|
||||
;
|
||||
|
||||
boost-install boost_program_options ;
|
||||
install dist-lib
|
||||
:
|
||||
boost_program_options
|
||||
:
|
||||
<install-type>LIB
|
||||
<location>../../../dist/lib
|
||||
;
|
||||
|
||||
explicit dist-lib ;
|
||||
@@ -3,8 +3,6 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See www.boost.org/libs/program_options for documentation.
|
||||
|
||||
#ifndef PROGRAM_OPTIONS_VP_2003_05_19
|
||||
#define PROGRAM_OPTIONS_VP_2003_05_19
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace boost { namespace program_options {
|
||||
: detail::cmdline(
|
||||
// Explicit template arguments are required by gcc 3.3.1
|
||||
// (at least mingw version), and do no harm on other compilers.
|
||||
to_internal(detail::make_vector<charT, charT**>(argv+1, argv+argc+!argc)))
|
||||
to_internal(detail::make_vector<charT, charT**>(argv+1, argv+argc)))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@@ -98,10 +98,10 @@ namespace boost { namespace program_options { namespace detail {
|
||||
{
|
||||
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
vector<string> args;
|
||||
copy(argv+1, argv+argc+!argc, inserter(args, args.end()));
|
||||
copy(argv+1, argv+argc, inserter(args, args.end()));
|
||||
init(args);
|
||||
#else
|
||||
init(vector<string>(argv+1, argv+argc+!argc));
|
||||
init(vector<string>(argv+1, argv+argc));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -290,8 +290,8 @@ namespace boost { namespace program_options { namespace detail {
|
||||
|
||||
// First check that the option is valid, and get its description.
|
||||
// TODO: case-sensitivity.
|
||||
const option_description* xd = m_desc->find_nothrow(opt.string_key,
|
||||
(m_style & allow_guessing) ? true : false);
|
||||
const option_description* xd =
|
||||
m_desc->find_nothrow(opt.string_key, (m_style & allow_guessing));
|
||||
|
||||
if (!xd)
|
||||
{
|
||||
@@ -470,8 +470,7 @@ namespace boost { namespace program_options { namespace detail {
|
||||
((m_style & allow_slash_for_short) && tok[0] == '/')))
|
||||
{
|
||||
if (m_desc->find_nothrow(tok.substr(1, tok.find('=')-1),
|
||||
(m_style & allow_guessing) ? true : false))
|
||||
{
|
||||
m_style & allow_guessing)) {
|
||||
args[0].insert(0, "-");
|
||||
if (args[0][1] == '/')
|
||||
args[0][1] = '-';
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace boost { namespace program_options {
|
||||
{
|
||||
// is last_space within the second half ot the
|
||||
// current line
|
||||
if ((unsigned)distance(last_space, line_end) <
|
||||
if (unsigned(distance(last_space, line_end)) <
|
||||
(line_length - indent) / 2)
|
||||
{
|
||||
line_end = last_space;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
project
|
||||
: requirements
|
||||
<library>../build//boost_program_options
|
||||
<library>/boost/test//boost_test_exec_monitor/<link>static
|
||||
<link>static
|
||||
<variant>debug
|
||||
|
||||
# <define>_GLIBCXX_CONCEPT_CHECKS
|
||||
# <define>_GLIBCXX_DEBUG
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
using namespace boost::program_options;
|
||||
using boost::program_options::detail::cmdline;
|
||||
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
using namespace std;
|
||||
|
||||
#include "minitest.hpp"
|
||||
|
||||
/* To facilitate testing, declare a number of error codes. Otherwise,
|
||||
we'd have to specify the type of exception that should be thrown.
|
||||
*/
|
||||
@@ -599,7 +600,7 @@ void test_unregistered()
|
||||
// It's not clear yet, so I'm leaving the decision till later.
|
||||
}
|
||||
|
||||
int main(int ac, char* av[])
|
||||
int test_main(int ac, char* av[])
|
||||
{
|
||||
test_long_options();
|
||||
test_short_options();
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef BOOST_PROGRAM_OPTIONS_MINITEST
|
||||
#define BOOST_PROGRAM_OPTIONS_MINITEST
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BOOST_REQUIRE(b) assert(b)
|
||||
#define BOOST_CHECK(b) assert(b)
|
||||
#define BOOST_CHECK_EQUAL(a, b) assert(a == b)
|
||||
#define BOOST_ERROR(description) std::cerr << description; std::cerr << "\n"; abort();
|
||||
#define BOOST_CHECK_THROW(expression, exception) \
|
||||
try \
|
||||
{ \
|
||||
expression; \
|
||||
BOOST_ERROR("expected exception not thrown");\
|
||||
throw 10; \
|
||||
} \
|
||||
catch(exception &) \
|
||||
{ \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -10,13 +10,14 @@ using namespace boost::program_options;
|
||||
#include <boost/function.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include "minitest.hpp"
|
||||
|
||||
void test_type()
|
||||
{
|
||||
options_description desc;
|
||||
@@ -76,7 +77,7 @@ void test_formatting()
|
||||
ss << desc;
|
||||
}
|
||||
|
||||
int main(int, char* [])
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_type();
|
||||
test_approximation();
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace po = boost::program_options;
|
||||
#include <boost/function.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
@@ -24,8 +27,6 @@ using namespace std;
|
||||
#include <cstdlib> // for putenv
|
||||
#endif
|
||||
|
||||
#include "minitest.hpp"
|
||||
|
||||
#define TEST_CHECK_THROW(expression, exception, description) \
|
||||
try \
|
||||
{ \
|
||||
@@ -258,7 +259,7 @@ void test_unregistered()
|
||||
check_value(a3[1], "m1.v1", "1");
|
||||
}
|
||||
|
||||
int main(int, char* [])
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_command_line();
|
||||
test_config_file();
|
||||
|
||||
@@ -12,8 +12,7 @@ namespace po = boost::program_options;
|
||||
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
#include "minitest.hpp"
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
@@ -82,7 +81,7 @@ void test_parsing()
|
||||
too_many_positional_options_error);
|
||||
}
|
||||
|
||||
int main(int, char* [])
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_positional_options();
|
||||
test_parsing();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <boost/program_options/detail/convert.hpp>
|
||||
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#include "minitest.hpp"
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -121,7 +121,7 @@ void test_convert(const std::string& input,
|
||||
BOOST_CHECK(ref == input);
|
||||
}
|
||||
|
||||
int main(int ac, char* av[])
|
||||
int test_main(int ac, char* av[])
|
||||
{
|
||||
std::string input = file_content("utf8.txt");
|
||||
std::string expected = file_content("ucs2.txt");
|
||||
|
||||
@@ -15,11 +15,12 @@ namespace po = boost::program_options;
|
||||
#include <boost/function.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include "minitest.hpp"
|
||||
|
||||
// Test that unicode input is forwarded to unicode option without
|
||||
// problems.
|
||||
void test_unicode_to_unicode()
|
||||
@@ -148,7 +149,7 @@ void test_config_file()
|
||||
BOOST_CHECK(vm["foo"].as<string>() == "\xD1\x8F");
|
||||
}
|
||||
|
||||
int main(int, char* [])
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_unicode_to_unicode();
|
||||
test_unicode_to_native();
|
||||
|
||||
@@ -15,10 +15,22 @@ namespace po = boost::program_options;
|
||||
#include <boost/function.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include "minitest.hpp"
|
||||
#define TEST_CHECK_THROW(expression, exception, description) \
|
||||
try \
|
||||
{ \
|
||||
expression; \
|
||||
BOOST_ERROR(description);\
|
||||
throw 10; \
|
||||
} \
|
||||
catch(exception &) \
|
||||
{ \
|
||||
}
|
||||
|
||||
vector<string> sv(char* array[], unsigned size)
|
||||
{
|
||||
@@ -276,7 +288,7 @@ void test_multiple_assignments_with_different_option_description()
|
||||
|
||||
}
|
||||
|
||||
int main(int, char* [])
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_variable_map();
|
||||
test_semantic_values();
|
||||
|
||||
@@ -7,42 +7,26 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <boost/program_options/parsers.hpp>
|
||||
using namespace boost::program_options;
|
||||
|
||||
void check_equal(const std::vector<string>& actual, char **expected, int n)
|
||||
{
|
||||
if (actual.size() != n)
|
||||
{
|
||||
std::cerr << "Size mismatch between expected and actual data\n";
|
||||
abort();
|
||||
}
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (actual[i] != expected[i])
|
||||
{
|
||||
std::cerr << "Unexpected content\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
|
||||
void test_winmain()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
#define C ,
|
||||
#define TEST(input, expected) \
|
||||
char* BOOST_PP_CAT(e, __LINE__)[] = expected;\
|
||||
vector<string> BOOST_PP_CAT(v, __LINE__) = split_winmain(input);\
|
||||
check_equal(BOOST_PP_CAT(v, __LINE__), BOOST_PP_CAT(e, __LINE__),\
|
||||
sizeof(BOOST_PP_CAT(e, __LINE__))/sizeof(char*));
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(BOOST_PP_CAT(v, __LINE__).begin(),\
|
||||
BOOST_PP_CAT(v, __LINE__).end(),\
|
||||
BOOST_PP_CAT(e, __LINE__),\
|
||||
BOOST_PP_CAT(e, __LINE__) + \
|
||||
sizeof(BOOST_PP_CAT(e, __LINE__))/sizeof(char*));
|
||||
|
||||
// The following expectations were obtained in Win2000 shell:
|
||||
TEST("1 ", {"1"});
|
||||
@@ -61,13 +45,13 @@ void test_winmain()
|
||||
TEST("1\\\\1 ", {"1\\\\1"});
|
||||
}
|
||||
|
||||
int main(int, char*[])
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
test_winmain();
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int main(int, char*[])
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user