Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57515 - trunk/libs/program_options/test
From: ghost_at_[hidden]
Date: 2009-11-09 10:57:51


Author: vladimir_prus
Date: 2009-11-09 10:57:51 EST (Mon, 09 Nov 2009)
New Revision: 57515
URL: http://svn.boost.org/trac/boost/changeset/57515

Log:
Test for \t-alignment of options descriptions.

Fixes #1527.
Patch from Sascha Ochsenknecht.

Text files modified:
   trunk/libs/program_options/test/options_description_test.cpp | 49 ++++++++++++++++++++++++++++++++++-----
   1 files changed, 42 insertions(+), 7 deletions(-)

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 10:57:51 EST (Mon, 09 Nov 2009)
@@ -22,7 +22,7 @@
     options_description desc;
     desc.add_options()
         ("foo", value<int>(), "")
- ("bar", value<std::string>(), "")
+ ("bar", value<string>(), "")
         ;
     
     const typed_value_base* b = dynamic_cast<const typed_value_base*>
@@ -33,7 +33,7 @@
     const typed_value_base* b2 = dynamic_cast<const typed_value_base*>
         (desc.find("bar", false).semantic().get());
     BOOST_CHECK(b2);
- BOOST_CHECK(b2->value_type() == typeid(std::string));
+ BOOST_CHECK(b2->value_type() == typeid(string));
 }
 
 void test_approximation()
@@ -70,10 +70,45 @@
         "foo foo foo foo foo foo foo foo foo foo foo foo foo foo"
         "foo foo foo foo foo foo foo foo foo foo foo foo foo foo"
         "foo foo foo foo foo foo foo foo foo foo foo foo foo foo"
- "foo foo foo foo foo foo foo foo foo foo foo foo foo foo");
+ "foo foo foo foo foo foo foo foo foo foo foo foo foo foo")
+ ("list", new untyped_value(),
+ "a list:\n \t"
+ "item1, item2, item3, item4, item5, item6, item7, item8, item9, "
+ "item10, item11, item12, item13, item14, item15, item16, item17, item18")
+ ("well_formated", new untyped_value(),
+ "As you can see this is a very well formatted option description.\n"
+ "You can do this for example:\n\n"
+ "Values:\n"
+ " Value1: \tdoes this and that, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\n"
+ " Value2: \tdoes something else, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\n\n"
+ " This paragraph has a first line indent only, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla")
+ ;
 
     stringstream ss;
     ss << desc;
+ BOOST_CHECK_EQUAL(ss.str(),
+" --test arg foo foo foo foo foo foo foo foo foo foo foo foo foo \n"
+" foofoo foo foo foo foo foo foo foo foo foo foo foo foo \n"
+" foofoo foo foo foo foo foo foo foo foo foo foo foo foo \n"
+" foofoo foo foo foo foo foo foo foo foo foo foo foo foo \n"
+" foo\n"
+" --list arg a list:\n"
+" item1, item2, item3, item4, item5, item6, item7, \n"
+" item8, item9, item10, item11, item12, item13, item14, \n"
+" item15, item16, item17, item18\n"
+" --well_formated arg As you can see this is a very well formatted option \n"
+" description.\n"
+" You can do this for example:\n"
+" \n"
+" Values:\n"
+" Value1: does this and that, bla bla bla bla bla bla \n"
+" bla bla bla bla bla bla bla bla bla\n"
+" Value2: does something else, bla bla bla bla bla bla \n"
+" bla bla bla bla bla bla bla bla bla\n"
+" \n"
+" This paragraph has a first line indent only, bla \n"
+" bla bla bla bla bla bla bla bla bla bla bla bla bla bla\n"
+ );
 }
 
 void test_long_default_value()
@@ -81,16 +116,16 @@
     options_description desc;
     desc.add_options()
         ("cfgfile,c",
- value<std::string>()->default_value("/usr/local/etc/myprogramXXXXXXXXX/configuration.conf"),
- "the configfile");
+ value<string>()->default_value("/usr/local/etc/myprogramXXXXXXXXX/configuration.conf"),
+ "the configfile")
+ ;
 
     stringstream ss;
     ss << desc;
     BOOST_CHECK_EQUAL(ss.str(),
 " -c [ --cfgfile ] arg (=/usr/local/etc/myprogramXXXXXXXXX/configuration.conf)\n"
 " the configfile\n"
- );
-
+ );
 }
 
 int main(int, char* [])


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