Ticket #2613: patch_ticket2613.diff

File patch_ticket2613.diff, 2.7 KB (added by s.ochsenknecht@…, 13 years ago)

patch

  • libs/program_options/test/options_description_test.cpp

     
    9393
    9494}
    9595
     96void test_word_wrapping()
     97{
     98   options_description desc("Supported options");
     99   desc.add_options()
     100      ("help",    "this is a sufficiently long text to require word-wrapping")
     101      ("prefix", value<string>()->default_value("/h/proj/tmp/dispatch"), "root path of the dispatch installation")
     102      ("opt1",    "this_is_a_sufficiently_long_text_to_require_word-wrapping_but_cannot_be_wrapped")
     103      ("opt2",    "this_is_a_sufficiently long_text_to_require_word-wrapping")
     104      ("opt3",    "this_is_a sufficiently_long_text_to_require_word-wrapping_but_will_not_be_wrapped")
     105      ;
     106    stringstream ss;
     107    ss << desc;   
     108    BOOST_CHECK_EQUAL(ss.str(),
     109"Supported options:\n"
     110"  --help                               this is a sufficiently long text to \n"
     111"                                       require word-wrapping\n"
     112"  --prefix arg (=/h/proj/tmp/dispatch) root path of the dispatch installation\n"
     113"  --opt1                               this_is_a_sufficiently_long_text_to_requ\n"
     114"                                       ire_word-wrapping_but_cannot_be_wrapped\n"
     115"  --opt2                               this_is_a_sufficiently \n"
     116"                                       long_text_to_require_word-wrapping\n"
     117"  --opt3                               this_is_a sufficiently_long_text_to_requ\n"
     118"                                       ire_word-wrapping_but_will_not_be_wrappe\n"
     119"                                       d\n"
     120   );
     121}
     122
    96123int main(int, char* [])
    97124{
    98125    test_type();
    99126    test_approximation();
    100127    test_formatting();
    101128    test_long_default_value();
     129    test_word_wrapping();
    102130    return 0;
    103131}
  • libs/program_options/src/options_description.cpp

     
    410410                        {                 
    411411                            // is last_space within the second half ot the
    412412                            // current line
    413                             if ((unsigned)distance(last_space, line_end) <
    414                                 (line_length - indent) / 2)
     413                            if (static_cast<unsigned>(distance(last_space, line_end)) <
     414                                (line_length / 2))
    415415                            {
    416416                                line_end = last_space;
    417417                            }