|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57517 - in trunk/libs/program_options: src test
From: ghost_at_[hidden]
Date: 2009-11-09 11:12:32
Author: vladimir_prus
Date: 2009-11-09 11:12:31 EST (Mon, 09 Nov 2009)
New Revision: 57517
URL: http://svn.boost.org/trac/boost/changeset/57517
Log:
Fix wordwrapping in presense of default parameters.
Fixes #2613.
Patch from Sascha Ochsenknecht.
Text files modified:
trunk/libs/program_options/src/options_description.cpp | 4 ++--
trunk/libs/program_options/test/options_description_test.cpp | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
Modified: trunk/libs/program_options/src/options_description.cpp
==============================================================================
--- trunk/libs/program_options/src/options_description.cpp (original)
+++ trunk/libs/program_options/src/options_description.cpp 2009-11-09 11:12:31 EST (Mon, 09 Nov 2009)
@@ -410,8 +410,8 @@
{
// is last_space within the second half ot the
// current line
- if ((unsigned)distance(last_space, line_end) <
- (line_length - indent) / 2)
+ if (static_cast<unsigned>(distance(last_space, line_end)) <
+ (line_length / 2))
{
line_end = last_space;
}
Modified: trunk/libs/program_options/test/options_description_test.cpp
==============================================================================
--- trunk/libs/program_options/test/options_description_test.cpp (original)
+++ trunk/libs/program_options/test/options_description_test.cpp 2009-11-09 11:12:31 EST (Mon, 09 Nov 2009)
@@ -128,11 +128,39 @@
);
}
+void test_word_wrapping()
+{
+ options_description desc("Supported options");
+ desc.add_options()
+ ("help", "this is a sufficiently long text to require word-wrapping")
+ ("prefix", value<string>()->default_value("/h/proj/tmp/dispatch"), "root path of the dispatch installation")
+ ("opt1", "this_is_a_sufficiently_long_text_to_require_word-wrapping_but_cannot_be_wrapped")
+ ("opt2", "this_is_a_sufficiently long_text_to_require_word-wrapping")
+ ("opt3", "this_is_a sufficiently_long_text_to_require_word-wrapping_but_will_not_be_wrapped")
+ ;
+ stringstream ss;
+ ss << desc;
+ BOOST_CHECK_EQUAL(ss.str(),
+"Supported options:\n"
+" --help this is a sufficiently long text to \n"
+" require word-wrapping\n"
+" --prefix arg (=/h/proj/tmp/dispatch) root path of the dispatch installation\n"
+" --opt1 this_is_a_sufficiently_long_text_to_requ\n"
+" ire_word-wrapping_but_cannot_be_wrapped\n"
+" --opt2 this_is_a_sufficiently \n"
+" long_text_to_require_word-wrapping\n"
+" --opt3 this_is_a sufficiently_long_text_to_requ\n"
+" ire_word-wrapping_but_will_not_be_wrappe\n"
+" d\n"
+ );
+}
+
int main(int, char* [])
{
test_type();
test_approximation();
test_formatting();
test_long_default_value();
+ test_word_wrapping();
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk