LCOV - code coverage report
Current view: top level - tests - catch_usage.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1881 1881
Test Date: 2026-01-18 09:38:57 Functions: 100.0 % 17 17
Legend: Lines: hit not hit

            Line data    Source code
       1              : // Copyright (c) 2006-2025  Made to Order Software Corp.  All Rights Reserved
       2              : //
       3              : // https://snapwebsites.org/project/advgetopt
       4              : // contact@m2osw.com
       5              : //
       6              : // This program is free software; you can redistribute it and/or modify
       7              : // it under the terms of the GNU General Public License as published by
       8              : // the Free Software Foundation; either version 2 of the License, or
       9              : // (at your option) any later version.
      10              : //
      11              : // This program is distributed in the hope that it will be useful,
      12              : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14              : // GNU General Public License for more details.
      15              : //
      16              : // You should have received a copy of the GNU General Public License along
      17              : // with this program; if not, write to the Free Software Foundation, Inc.,
      18              : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19              : 
      20              : // advgetopt
      21              : //
      22              : #include    <advgetopt/flags.h>
      23              : #include    <advgetopt/exception.h>
      24              : 
      25              : 
      26              : // self
      27              : //
      28              : #include    "catch_main.h"
      29              : 
      30              : 
      31              : // snapdev
      32              : //
      33              : #include    <snapdev/safe_setenv.h>
      34              : 
      35              : 
      36              : // C++
      37              : //
      38              : #include    <fstream>
      39              : 
      40              : 
      41              : // last include
      42              : //
      43              : #include    <snapdev/poison.h>
      44              : 
      45              : 
      46              : 
      47              : 
      48              : 
      49              : 
      50              : 
      51            4 : CATCH_TEST_CASE("usage_function", "[getopt][usage]")
      52              : {
      53            4 :     std::string tmpdir(SNAP_CATCH2_NAMESPACE::g_tmp_dir());
      54            4 :     tmpdir += "/.config/home";
      55           12 :     snapdev::safe_setenv env("HOME", tmpdir);
      56              : 
      57            4 :     CATCH_START_SECTION("usage_function: usage() using \"--filename\" for the default option accepting multiple entries")
      58              :     {
      59            1 :         advgetopt::option const options_list[] =
      60              :         {
      61              :             advgetopt::define_option(
      62              :                   advgetopt::Name("validate")
      63              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
      64              :                 , advgetopt::Help("this is used to validate different things.")
      65              :             ),
      66              :             advgetopt::define_option(
      67              :                   advgetopt::Name("long")
      68              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
      69              :                                                            , advgetopt::GETOPT_FLAG_REQUIRED>())
      70              :                 , advgetopt::Help("used to validate that invalid numbers generate an error.")
      71              :             ),
      72              :             advgetopt::define_option(
      73              :                   advgetopt::Name("out-of-bounds")
      74              :                 , advgetopt::ShortName('o')
      75              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
      76              :                                                       , advgetopt::GETOPT_FLAG_GROUP_OPTIONS
      77              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
      78              :                 , advgetopt::Help("valid values from 1 to 9.")
      79              :             ),
      80              :             advgetopt::define_option(
      81              :                   advgetopt::Name("not-specified-and-no-default")
      82              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
      83              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED
      84              :                                                       , advgetopt::GETOPT_FLAG_GROUP_OPTIONS
      85              :                                                       , advgetopt::GETOPT_FLAG_SHOW_GROUP1>())
      86              :                 , advgetopt::Help("test long without having used the option and no default.")
      87              :             ),
      88              :             advgetopt::define_option(
      89              :                   advgetopt::Name("not-specified-with-invalid-default")
      90              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
      91              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED
      92              :                                                       , advgetopt::GETOPT_FLAG_MULTIPLE
      93              :                                                       , advgetopt::GETOPT_FLAG_SHOW_GROUP2>())
      94              :                 , advgetopt::Help("test that an invalid default value can be returned as is.")
      95              :                 , advgetopt::DefaultValue("123abc")
      96              :             ),
      97              :             advgetopt::define_option(
      98              :                   advgetopt::Name("not-specified-string-without-default")
      99              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
     100              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
     101              :                 , advgetopt::Alias("string")
     102              :             ),
     103              :             advgetopt::define_option(
     104              :                   advgetopt::Name("string")
     105              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
     106              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
     107              :                 , advgetopt::Help("string parameter.")
     108              :             ),
     109              :             advgetopt::define_option(
     110              :                   advgetopt::Name("unique")
     111              :                 , advgetopt::ShortName('u')
     112              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
     113              :                 , advgetopt::Help("make sure everything is unique.")
     114              :             ),
     115              :             advgetopt::define_option(
     116              :                   advgetopt::Name("noisy")
     117              :                 , advgetopt::ShortName('n')
     118              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR
     119              :                                                                      , advgetopt::GETOPT_FLAG_GROUP_COMMANDS>())
     120              :                 //, advgetopt::Help("make sure everything is unique.") -- do not show in --help
     121              :             ),
     122              :             advgetopt::define_option(
     123              :                   advgetopt::Name("quiet")
     124              :                 , advgetopt::ShortName('q')
     125              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
     126              :                                                       , advgetopt::GETOPT_FLAG_MULTIPLE
     127              :                                                       , advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR
     128              :                                                       , advgetopt::GETOPT_FLAG_GROUP_COMMANDS>())
     129              :                 , advgetopt::Help("make it quiet (opposite of verbose).")
     130              :             ),
     131              :             advgetopt::define_option(
     132              :                   advgetopt::Name("filename")
     133              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
     134              :                                                            , advgetopt::GETOPT_FLAG_MULTIPLE
     135              :                                                            , advgetopt::GETOPT_FLAG_DEFAULT_OPTION>())
     136              :                 , advgetopt::Help("other parameters are viewed as filenames.")
     137              :             ),
     138              :             advgetopt::end_options()
     139              :         };
     140            1 :         char const * cargv2[] =
     141              :         {
     142              :             "tests/unittests/unittest_advgetopt",
     143              :             "--validate",
     144              :             "--long",
     145              :             "123abc",
     146              :             "--out-of-bounds",
     147              :             "123",
     148              :             "--string",
     149              :             "string value",
     150              :             nullptr
     151              :         };
     152            1 :         int const argc2 = sizeof(cargv2) / sizeof(cargv2[0]) - 1;
     153            1 :         char ** argv2 = const_cast<char **>(cargv2);
     154              : 
     155            1 :         const char * const configuration_files[] =
     156              :         {
     157              :             // TODO: this is wrong, the programmer is expected to include
     158              :             //       a path to his direct configuration filenames
     159              :             //
     160              :             "advgetopt.conf",
     161              :             "advgetopt.ini",
     162              :             "advgetopt.xml",
     163              :             "advgetopt.yaml",
     164              :             nullptr
     165              :         };
     166              : 
     167            1 :         const char * const configuration_directories[] =
     168              :         {
     169              :             "/etc/sys/advgetopt",
     170              :             "/etc/advgetopt",
     171              :             "/etc/advgetopt/advgetopt.d",
     172              :             "~/.config/advgetopt",
     173              :             nullptr
     174              :         };
     175              : 
     176            1 :         advgetopt::group_description const groups[] =
     177              :         {
     178              :             advgetopt::define_group(
     179              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_COMMANDS)
     180              :                 , advgetopt::GroupName("verbosity")
     181              :                 , advgetopt::GroupDescription("Verbosity options:")
     182              :             ),
     183              :             advgetopt::define_group(
     184              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_OPTIONS)
     185              :                 , advgetopt::GroupName("option")
     186              :                 , advgetopt::GroupDescription("Special options:")
     187              :             ),
     188              :             advgetopt::end_groups()
     189              :         };
     190              : 
     191            1 :         advgetopt::options_environment options;
     192            1 :         options.f_project_name = "unittest";
     193            1 :         options.f_group_name = "grouptest";
     194            1 :         options.f_options = options_list;
     195            1 :         options.f_options_files_directory = "/etc/advgetopt";
     196            1 :         options.f_configuration_files = configuration_files;
     197            1 :         options.f_configuration_filename = "advgetopt.conf";
     198            1 :         options.f_configuration_directories = configuration_directories;
     199            1 :         options.f_help_header = "Usage: try this one and we get a throw (valid options + usage calls)";
     200            1 :         options.f_help_footer = "And this is the footer where we can include many parameters:\n"
     201              :                                 "   . Percent = [%%]\n"
     202              :                                 "   . Project Name = [%a]\n"
     203              :                                 "   . Build Date = [%b]\n"
     204              :                                 "   . Copyright = [%c]\n"
     205              :                                 "   . Directories = [%d]\n"
     206              :                                 "   . All Directories = [%*d]\n"
     207              :                                 "   . Environment Variable = [%e]\n"
     208              :                                 "   . Environment Variable and Value = [%*e]\n"
     209              :                                 "   . Environment Variable Intro = [%E]\n"
     210              :                                 "   . Configuration Files = [%f]\n"
     211              :                                 "   . All Configuration Files = [%*f]\n"
     212              :                                 "   . All Existing Configuration Files = [%g]\n"
     213              :                                 "   . All Possible Configuration Files = [%*g]\n"
     214              :                                 "   . Option Filename = [%i]\n"
     215              :                                 "   . License = [%l]\n"
     216              :                                 "   . Section Variable Name = [%m]\n"
     217              :                                 "   . Output File [%o]\n"
     218              :                                 "   . Program Name = [%p]\n"
     219              :                                 "   . Program Fullname = [%*p]\n"
     220              :                                 "   . Group Name = [%s]\n"
     221              :                                 "   . Build Time = [%t]\n"
     222              :                                 "   . Version = [%v]\n"
     223              :                                 "   . Existing Writable Configuration Files = [%w]\n"
     224              :                 ;
     225            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
     226            1 :         options.f_environment_variable_intro = "ADVGETOPT_";
     227            1 :         options.f_section_variables_name = "configvars";
     228            1 :         options.f_version = "2.0.1";
     229            1 :         options.f_license = "MIT";
     230            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved";
     231            1 :         options.f_build_date = "Jun  4 2019";
     232            1 :         options.f_build_time = "23:02:36";
     233            1 :         options.f_groups = groups;
     234              : 
     235              :         // this initialization works as expected
     236              :         //
     237            1 :         advgetopt::getopt opt(options, argc2, argv2);
     238              : 
     239            1 :         CATCH_REQUIRE(opt.get_group_name() == "grouptest");
     240              : 
     241              :         {
     242            1 :             advgetopt::group_description const * verbosity_group(opt.find_group(advgetopt::GETOPT_FLAG_GROUP_COMMANDS));
     243            1 :             CATCH_REQUIRE(verbosity_group != nullptr);
     244            1 :             CATCH_REQUIRE(verbosity_group->f_group == advgetopt::GETOPT_FLAG_GROUP_COMMANDS);
     245            3 :             CATCH_REQUIRE(verbosity_group->f_name == std::string("verbosity"));
     246            3 :             CATCH_REQUIRE(verbosity_group->f_description == std::string("Verbosity options:"));
     247              :         }
     248              : 
     249              :         {
     250            1 :             advgetopt::group_description const * option_group(opt.find_group(advgetopt::GETOPT_FLAG_GROUP_OPTIONS));
     251            1 :             CATCH_REQUIRE(option_group != nullptr);
     252            1 :             CATCH_REQUIRE(option_group->f_group == advgetopt::GETOPT_FLAG_GROUP_OPTIONS);
     253            3 :             CATCH_REQUIRE(option_group->f_name == std::string("option"));
     254            3 :             CATCH_REQUIRE(option_group->f_description == std::string("Special options:"));
     255              :         }
     256              : 
     257              :         {
     258            1 :             advgetopt::group_description const * group_seven(opt.find_group(advgetopt::GETOPT_FLAG_GROUP_SEVEN));
     259            1 :             CATCH_REQUIRE(group_seven == nullptr);
     260              :         }
     261              : 
     262            1 :         std::string const footer(advgetopt::breakup_line(
     263              : "\n"
     264              : "And this is the footer where we can include many parameters:\n"
     265              : "   . Percent = [%]\n"
     266              : "   . Project Name = [unittest]\n"
     267              : "   . Build Date = [Jun  4 2019]\n"
     268              : "   . Copyright = [Copyright (c) 2019  Made to Order Software Corp. -- All Rights "
     269              : "Reserved]\n"
     270              : "   . Directories = [/etc/sys/advgetopt]\n"
     271              : "   . All Directories = [/etc/sys/advgetopt, /etc/advgetopt, "
     272              : "/etc/advgetopt/advgetopt.d, ~/.config/advgetopt]\n"
     273              : "   . Environment Variable = [ADVGETOPT_TEST_OPTIONS]\n"
     274              : "   . Environment Variable and Value = [ADVGETOPT_TEST_OPTIONS (not set)]\n"
     275              : "   . Environment Variable Intro = [ADVGETOPT_]\n"
     276              : "   . Configuration Files = [advgetopt.conf]\n"
     277              : "   . All Configuration Files = [advgetopt.conf, advgetopt.ini, advgetopt.xml, "
     278              : "advgetopt.yaml]\n"
     279              : "   . All Existing Configuration Files = []\n"
     280              : "   . All Possible Configuration Files = ["
     281              : "/etc/sys/advgetopt/advgetopt.conf, "
     282              : "/etc/sys/advgetopt/grouptest.d/50-advgetopt.conf, /etc/advgetopt/advgetopt.conf, "
     283              : "/etc/advgetopt/grouptest.d/50-advgetopt.conf, "
     284              : "/etc/advgetopt/advgetopt.d/advgetopt.conf, "
     285              : "/etc/advgetopt/advgetopt.d/grouptest.d/50-advgetopt.conf, "
     286            2 : + tmpdir + "/.config/advgetopt/advgetopt.conf, "
     287              : "advgetopt.conf, "
     288              : "grouptest.d/50-advgetopt.conf, advgetopt.ini, grouptest.d/50-advgetopt.ini, "
     289              : "advgetopt.xml, grouptest.d/50-advgetopt.xml, advgetopt.yaml, "
     290              : "grouptest.d/50-advgetopt.yaml]\n"
     291              : "   . Option Filename = [/etc/advgetopt/grouptest.ini]\n"
     292              : "   . License = [MIT]\n"
     293              : "   . Section Variable Name = [configvars]\n"
     294              : "   . Output File [grouptest.d/50-advgetopt.yaml]\n"
     295              : "   . Program Name = [unittest_advgetopt]\n"
     296              : "   . Program Fullname = [tests/unittests/unittest_advgetopt]\n"
     297              : "   . Group Name = [grouptest]\n"
     298              : "   . Build Time = [23:02:36]\n"
     299              : "   . Version = [2.0.1]\n"
     300              : "   . Existing Writable Configuration Files = []\n"
     301            2 : "", 0, advgetopt::get_screen_width()));
     302              : 
     303              :         // test a standard "--help" type of option
     304              :         //
     305            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
     306           43 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
     307              : advgetopt::breakup_line(
     308              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     309              :             , 0
     310              :             , advgetopt::get_screen_width())
     311              : + advgetopt::format_usage_string(
     312              :               "--long <arg>"
     313              :             , "used to validate that invalid numbers generate an error."
     314              :             , 30
     315              :             , advgetopt::get_screen_width())
     316              : + advgetopt::format_usage_string(
     317              :               "--string or --not-specified-string-without-default <arg>"
     318              :             , "string parameter."
     319              :             , 30
     320              :             , advgetopt::get_screen_width())
     321              : + advgetopt::format_usage_string(
     322              :               "--unique or -u"
     323              :             , "make sure everything is unique."
     324              :             , 30
     325              :             , advgetopt::get_screen_width())
     326              : + advgetopt::format_usage_string(
     327              :               "--validate"
     328              :             , "this is used to validate different things."
     329              :             , 30
     330              :             , advgetopt::get_screen_width())
     331              : + "\n"
     332              :   "Verbosity options:\n"
     333              : + advgetopt::format_usage_string(
     334              :               "--long-help or -?"
     335              :             , "show all the help from all the available options."
     336              :             , 30
     337              :             , advgetopt::get_screen_width())
     338              : + advgetopt::format_usage_string(
     339              :               "--option-help"
     340              :             , "show help from the \"option\" group of options."
     341              :             , 30
     342              :             , advgetopt::get_screen_width())
     343              : + advgetopt::format_usage_string(
     344              :               "--quiet or -q {<arg>}"
     345              :             , "make it quiet (opposite of verbose)."
     346              :             , 30
     347              :             , advgetopt::get_screen_width())
     348              : + advgetopt::format_usage_string(
     349              :               "--verbosity-help"
     350              :             , "show help from the \"verbosity\" group of options."
     351              :             , 30
     352              :             , advgetopt::get_screen_width())
     353              : + "\n"
     354              :   "Special options:\n"
     355              : + advgetopt::format_usage_string(
     356              :               "--out-of-bounds or -o <arg>"
     357              :             , "valid values from 1 to 9."
     358              :             , 30
     359              :             , advgetopt::get_screen_width())
     360              : + advgetopt::format_usage_string(
     361              :               "[default arguments]"
     362              :             , "other parameters are viewed as filenames."
     363              :             , 30
     364              :             , advgetopt::get_screen_width())
     365              : + footer
     366              :                         );
     367              : 
     368              :         // test a "--help-all" type of option
     369              :         //
     370           51 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_ALL),
     371              : advgetopt::breakup_line(
     372              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     373              :             , 0
     374              :             , advgetopt::get_screen_width())
     375              : + advgetopt::format_usage_string(
     376              :               "--long <arg>"
     377              :             , "used to validate that invalid numbers generate an error."
     378              :             , 30
     379              :             , advgetopt::get_screen_width())
     380              : + advgetopt::format_usage_string(
     381              :               "--not-specified-with-invalid-default <arg> {<arg>}"
     382              :               " (default is \"123abc\")"
     383              :             , "test that an invalid default value can be returned as is."
     384              :             , 30
     385              :             , advgetopt::get_screen_width())
     386              : + advgetopt::format_usage_string(
     387              :               "--string or --not-specified-string-without-default <arg>"
     388              :             , "string parameter."
     389              :             , 30
     390              :             , advgetopt::get_screen_width())
     391              : + advgetopt::format_usage_string(
     392              :               "--unique or -u"
     393              :             , "make sure everything is unique."
     394              :             , 30
     395              :             , advgetopt::get_screen_width())
     396              : + advgetopt::format_usage_string(
     397              :               "--validate"
     398              :             , "this is used to validate different things."
     399              :             , 30
     400              :             , advgetopt::get_screen_width())
     401              : + "\n"
     402              :   "Verbosity options:\n"
     403              : + advgetopt::format_usage_string(
     404              :               "--long-help or -?"
     405              :             , "show all the help from all the available options."
     406              :             , 30
     407              :             , advgetopt::get_screen_width())
     408              : + advgetopt::format_usage_string(
     409              :               "--option-help"
     410              :             , "show help from the \"option\" group of options."
     411              :             , 30
     412              :             , advgetopt::get_screen_width())
     413              : + advgetopt::format_usage_string(
     414              :               "--quiet or -q {<arg>}"
     415              :             , "make it quiet (opposite of verbose)."
     416              :             , 30
     417              :             , advgetopt::get_screen_width())
     418              : + advgetopt::format_usage_string(
     419              :               "--verbosity-help"
     420              :             , "show help from the \"verbosity\" group of options."
     421              :             , 30
     422              :             , advgetopt::get_screen_width())
     423              : + "\n"
     424              :   "Special options:\n"
     425              : + advgetopt::format_usage_string(
     426              :               "--not-specified-and-no-default <arg>"
     427              :             , "test long without having used the option and no default."
     428              :             , 30
     429              :             , advgetopt::get_screen_width())
     430              : + advgetopt::format_usage_string(
     431              :               "--out-of-bounds or -o <arg>"
     432              :             , "valid values from 1 to 9."
     433              :             , 30
     434              :             , advgetopt::get_screen_width())
     435              : + advgetopt::format_usage_string(
     436              :               "[default arguments]"
     437              :             , "other parameters are viewed as filenames."
     438              :             , 30
     439              :             , advgetopt::get_screen_width())
     440              : + footer
     441              :                         );
     442              : 
     443              :         // pretend an error occurred
     444              :         //
     445           11 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR),
     446              : advgetopt::breakup_line(
     447              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     448              :             , 0
     449              :             , advgetopt::get_screen_width())
     450              : + advgetopt::format_usage_string(
     451              :               "--validate"
     452              :             , "this is used to validate different things."
     453              :             , 30
     454              :             , advgetopt::get_screen_width())
     455              : + "\n"
     456              :   "Verbosity options:\n"
     457              : + advgetopt::format_usage_string(
     458              :               "--quiet or -q {<arg>}"
     459              :             , "make it quiet (opposite of verbose)."
     460              :             , 30
     461              :             , advgetopt::get_screen_width())
     462              : + footer
     463              :                         );
     464              : 
     465              :         // show GROUP1
     466              :         //
     467            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_GROUP1),
     468              : advgetopt::breakup_line(
     469              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     470              :             , 0
     471              :             , advgetopt::get_screen_width())
     472              : + "\n"
     473              :   "Special options:\n"
     474              : + advgetopt::format_usage_string(
     475              :               "--not-specified-and-no-default <arg>"
     476              :             , "test long without having used the option and no default."
     477              :             , 30
     478              :             , advgetopt::get_screen_width())
     479              : + footer
     480              :                         );
     481              : 
     482              :         // show GROUP2
     483              :         //
     484            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_GROUP2),
     485              : advgetopt::breakup_line(
     486              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     487              :             , 0
     488              :             , advgetopt::get_screen_width())
     489              : + advgetopt::format_usage_string(
     490              :               "--not-specified-with-invalid-default <arg> {<arg>} (default is \"123abc\")"
     491              :             , "test that an invalid default value can be returned as is."
     492              :             , 30
     493              :             , advgetopt::get_screen_width())
     494              : + footer
     495              :                         );
     496            1 :     }
     497            4 :     CATCH_END_SECTION()
     498              : 
     499            4 :     CATCH_START_SECTION("usage_function: usage() using \"--filename\" for the default option accepting multiple entries which are required when \"--filename\" is used")
     500              :     {
     501            1 :         const advgetopt::option options_list[] =
     502              :         {
     503              :             advgetopt::define_option(
     504              :                   advgetopt::Name("validate")
     505              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     506              :                 , advgetopt::Help("this is used to validate different things.")
     507              :             ),
     508              :             advgetopt::define_option(
     509              :                   advgetopt::Name("long")
     510              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     511              :                 , advgetopt::Help("used to validate that invalid numbers generate an error.")
     512              :             ),
     513              :             advgetopt::define_option(
     514              :                   advgetopt::Name("out-of-bounds")
     515              :                 , advgetopt::ShortName('o')
     516              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     517              :                 , advgetopt::Help("valid values from 1 to 9.")
     518              :             ),
     519              :             advgetopt::define_option(
     520              :                   advgetopt::Name("not-specified-and-no-default")
     521              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_SHOW_GROUP1>())
     522              :                 , advgetopt::Help("test long without having used the option and no default.")
     523              :             ),
     524              :             advgetopt::define_option(
     525              :                   advgetopt::Name("not-specified-with-invalid-default")
     526              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_MULTIPLE, advgetopt::GETOPT_FLAG_SHOW_GROUP2>())
     527              :                 , advgetopt::Help("test that an invalid default value can be returned as is.")
     528              :                 , advgetopt::DefaultValue("123abc")
     529              :             ),
     530              :             advgetopt::define_option(
     531              :                   advgetopt::Name("not-specified-string-without-default")
     532              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     533              :                 , advgetopt::EnvironmentVariableName("String")
     534              :                 , advgetopt::Alias("string")
     535              :             ),
     536              :             advgetopt::define_option(
     537              :                   advgetopt::Name("string")
     538              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     539              :                 , advgetopt::EnvironmentVariableName("String")
     540              :                 , advgetopt::Help("string parameter.")
     541              :             ),
     542              :             advgetopt::define_option(
     543              :                   advgetopt::Name("unique")
     544              :                 , advgetopt::ShortName('u')
     545              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
     546              :                 , advgetopt::Help("make sure everything is unique.")
     547              :             ),
     548              :             advgetopt::define_option(
     549              :                   advgetopt::Name("noisy")
     550              :                 , advgetopt::ShortName('n')
     551              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     552              :                 //, advgetopt::Help("make sure everything is unique.") -- do not show in --help
     553              :             ),
     554              :             advgetopt::define_option(
     555              :                   advgetopt::Name("quiet")
     556              :                 , advgetopt::ShortName('q')
     557              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_ENVIRONMENT_VARIABLE, advgetopt::GETOPT_FLAG_MULTIPLE, advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     558              :                 , advgetopt::Help("make it quiet (opposite of verbose).")
     559              :             ),
     560              :             advgetopt::define_option(
     561              :                   advgetopt::Name("filename")
     562              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_MULTIPLE, advgetopt::GETOPT_FLAG_DEFAULT_OPTION>())
     563              :                 , advgetopt::Help("other parameters are viewed as filenames.")
     564              :             ),
     565              :             advgetopt::end_options()
     566              :         };
     567            1 :         char const * cargv2[] =
     568              :         {
     569              :             "tests/unittests/unittest_advgetopt",
     570              :             "--validate",
     571              :             "--long",
     572              :             "123abc",
     573              :             "--out-of-bounds",
     574              :             "123",
     575              :             "--string",
     576              :             "string value",
     577              :             nullptr
     578              :         };
     579            1 :         int const argc2 = sizeof(cargv2) / sizeof(cargv2[0]) - 1;
     580            1 :         char ** argv2 = const_cast<char **>(cargv2);
     581              : 
     582            1 :         const char * const configuration_files[] =
     583              :         {
     584              :             // TODO: these are wrong, the developer defined names need to
     585              :             //       include a path
     586              :             //
     587              :             "advgetopt.conf",
     588              :             "advgetopt.ini",
     589              :             "advgetopt.xml",
     590              :             "advgetopt.yaml",
     591              :             nullptr
     592              :         };
     593              : 
     594            1 :         const char * const configuration_directories[] =
     595              :         {
     596              :             "/etc/sys/advgetopt",
     597              :             "/etc/advgetopt",
     598              :             "/etc/advgetopt/advgetopt.d",
     599              :             "~/.config/advgetopt",
     600              :             nullptr
     601              :         };
     602              : 
     603            1 :         advgetopt::options_environment options;
     604            1 :         options.f_project_name = "unittest";
     605            1 :         options.f_options = options_list;
     606            1 :         options.f_options_files_directory = "/usr/share/advgetopt";
     607            1 :         options.f_configuration_files = configuration_files;
     608            1 :         options.f_configuration_filename = "advgetopt.conf";
     609            1 :         options.f_configuration_directories = configuration_directories;
     610            1 :         options.f_help_header = "Usage: try this one and we get a throw (valid options + usage calls)";
     611            1 :         options.f_help_footer = "And this is the footer where we can include many parameters:\n"
     612              :                                 "   . Percent = [%%]\n"
     613              :                                 "   . Project Name = [%a]\n"
     614              :                                 "   . Build Date = [%b]\n"
     615              :                                 "   . Copyright = [%c]\n"
     616              :                                 "   . Directories = [%d]\n"
     617              :                                 "   . All Directories = [%*d]\n"
     618              :                                 "   . Environment Variable = [%e]\n"
     619              :                                 "   . Environment Variable and Value = [%*e]\n"
     620              :                                 "   . Environment Variable Intro = [%E]\n"
     621              :                                 "   . Configuration Files = [%f]\n"
     622              :                                 "   . All Configuration Files = [%*f]\n"
     623              :                                 "   . All Existing Configuration Files = [%g]\n"
     624              :                                 "   . All Possible Configuration Files = [%*g]\n"
     625              :                                 "   . Option Filename = [%i]\n"
     626              :                                 "   . License = [%l]\n"
     627              :                                 "   . Section Variable Name = [%m]\n"
     628              :                                 "   . Output File [%o]\n"
     629              :                                 "   . Program Name = [%p]\n"
     630              :                                 "   . Program Fullname = [%*p]\n"
     631              :                                 "   . Build Time = [%t]\n"
     632              :                                 "   . Version = [%v]\n"
     633              :                                 "   . Existing Writable Configuration Files = [%w]\n"
     634              :                 ;
     635            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
     636            1 :         options.f_environment_variable_intro = "Different_";
     637            1 :         options.f_version = "2.0.1";
     638            1 :         options.f_license = "MIT";
     639            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved";
     640            1 :         options.f_build_date = "Jun  4 2019";
     641            1 :         options.f_build_time = "23:02:36";
     642              : 
     643            5 :         snapdev::safe_setenv env_var("ADVGETOPT_TEST_OPTIONS", "-q");
     644              : 
     645              :         // this initialization works as expected
     646              :         //
     647            1 :         advgetopt::getopt opt(options, argc2, argv2);
     648              : 
     649            1 :         CATCH_REQUIRE(opt.find_group(advgetopt::GETOPT_FLAG_GROUP_COMMANDS) == nullptr);
     650            1 :         CATCH_REQUIRE(opt.find_group(advgetopt::GETOPT_FLAG_GROUP_OPTIONS) == nullptr);
     651              :   
     652            1 :         std::string const footer(advgetopt::breakup_line(
     653              : "\n"
     654              : "And this is the footer where we can include many parameters:\n"
     655              : "   . Percent = [%]\n"
     656              : "   . Project Name = [unittest]\n"
     657              : "   . Build Date = [Jun  4 2019]\n"
     658              : "   . Copyright = [Copyright (c) 2019  Made to Order Software Corp. -- All Rights "
     659              : "Reserved]\n"
     660              : "   . Directories = [/etc/sys/advgetopt]\n"
     661              : "   . All Directories = [/etc/sys/advgetopt, /etc/advgetopt, "
     662              : "/etc/advgetopt/advgetopt.d, ~/.config/advgetopt]\n"
     663              : "   . Environment Variable = [ADVGETOPT_TEST_OPTIONS]\n"
     664              : "   . Environment Variable and Value = [ADVGETOPT_TEST_OPTIONS=-q]\n"
     665              : "   . Environment Variable Intro = [Different_]\n"
     666              : "   . Configuration Files = [advgetopt.conf]\n"
     667              : "   . All Configuration Files = [advgetopt.conf, advgetopt.ini, advgetopt.xml, "
     668              : "advgetopt.yaml]\n"
     669              : "   . All Existing Configuration Files = []\n"
     670              : "   . All Possible Configuration Files = ["
     671              : "/etc/sys/advgetopt/advgetopt.conf, "
     672              : "/etc/sys/advgetopt/unittest.d/50-advgetopt.conf, /etc/advgetopt/advgetopt.conf, "
     673              : "/etc/advgetopt/unittest.d/50-advgetopt.conf, "
     674              : "/etc/advgetopt/advgetopt.d/advgetopt.conf, "
     675              : "/etc/advgetopt/advgetopt.d/unittest.d/50-advgetopt.conf, "
     676            2 : + tmpdir + "/.config/advgetopt/advgetopt.conf, "
     677              : "advgetopt.conf, "
     678              : "unittest.d/50-advgetopt.conf, advgetopt.ini, unittest.d/50-advgetopt.ini, "
     679              : "advgetopt.xml, unittest.d/50-advgetopt.xml, advgetopt.yaml, "
     680              : "unittest.d/50-advgetopt.yaml]\n"
     681              : "   . Option Filename = [/usr/share/advgetopt/unittest.ini]\n"
     682              : "   . License = [MIT]\n"
     683              : "   . Section Variable Name = [%m]\n"
     684              : "   . Output File [unittest.d/50-advgetopt.yaml]\n"
     685              : "   . Program Name = [unittest_advgetopt]\n"
     686              : "   . Program Fullname = [tests/unittests/unittest_advgetopt]\n"
     687              : "   . Build Time = [23:02:36]\n"
     688              : "   . Version = [2.0.1]\n"
     689              : "   . Existing Writable Configuration Files = []\n"
     690            2 : , 0, advgetopt::get_screen_width()));
     691              : 
     692              :         // test a standard "--help" type of option
     693              :         //
     694            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
     695           35 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
     696              :   advgetopt::breakup_line(
     697              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     698              :             , 0
     699              :             , advgetopt::get_screen_width())
     700              : + advgetopt::format_usage_string(
     701              :               "--long <arg>"
     702              :             , "used to validate that invalid numbers generate an error."
     703              :             , 30
     704              :             , advgetopt::get_screen_width())
     705              : + advgetopt::format_usage_string(
     706              :               "--long-help or -?"
     707              :             , "show all the help from all the available options."
     708              :             , 30
     709              :             , advgetopt::get_screen_width())
     710              : + advgetopt::format_usage_string(
     711              :               "--out-of-bounds or -o <arg>"
     712              :             , "valid values from 1 to 9."
     713              :             , 30
     714              :             , advgetopt::get_screen_width())
     715              : + advgetopt::format_usage_string(
     716              :               "--quiet or -q {<arg>}"
     717              :             , "make it quiet (opposite of verbose)."
     718              :             , 30
     719              :             , advgetopt::get_screen_width())
     720              : + advgetopt::format_usage_string(
     721              :               "--string or --not-specified-string-without-default <arg>"
     722              :             , "string parameter."
     723              :               "\nEnvironment Variable Name: \"Different_String\""
     724              :             , 30
     725              :             , advgetopt::get_screen_width())
     726              : + advgetopt::format_usage_string(
     727              :               "--unique or -u"
     728              :             , "make sure everything is unique."
     729              :             , 30
     730              :             , advgetopt::get_screen_width())
     731              : + advgetopt::format_usage_string(
     732              :               "--validate"
     733              :             , "this is used to validate different things."
     734              :             , 30
     735              :             , advgetopt::get_screen_width())
     736              : + advgetopt::format_usage_string(
     737              :               "<default arguments>"
     738              :             , "other parameters are viewed as filenames."
     739              :             , 30
     740              :             , advgetopt::get_screen_width())
     741              : + footer
     742              :                         );
     743              : 
     744              :         // test a "--help-all" type of option
     745              :         //
     746           43 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_ALL),
     747              :   advgetopt::breakup_line(
     748              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     749              :             , 0
     750              :             , advgetopt::get_screen_width())
     751              : + advgetopt::format_usage_string(
     752              :               "--long <arg>"
     753              :             , "used to validate that invalid numbers generate an error."
     754              :             , 30
     755              :             , advgetopt::get_screen_width())
     756              : + advgetopt::format_usage_string(
     757              :               "--long-help or -?"
     758              :             , "show all the help from all the available options."
     759              :             , 30
     760              :             , advgetopt::get_screen_width())
     761              : + advgetopt::format_usage_string(
     762              :               "--not-specified-and-no-default <arg>"
     763              :             , "test long without having used the option and no default."
     764              :             , 30
     765              :             , advgetopt::get_screen_width())
     766              : + advgetopt::format_usage_string(
     767              :               "--not-specified-with-invalid-default <arg> {<arg>} (default is \"123abc\")"
     768              :             , "test that an invalid default value can be returned as is."
     769              :             , 30
     770              :             , advgetopt::get_screen_width())
     771              : + advgetopt::format_usage_string(
     772              :               "--out-of-bounds or -o <arg>"
     773              :             , "valid values from 1 to 9."
     774              :             , 30
     775              :             , advgetopt::get_screen_width())
     776              : + advgetopt::format_usage_string(
     777              :               "--quiet or -q {<arg>}"
     778              :             , "make it quiet (opposite of verbose)."
     779              :             , 30
     780              :             , advgetopt::get_screen_width())
     781              : + advgetopt::format_usage_string(
     782              :               "--string or --not-specified-string-without-default <arg>"
     783              :             , "string parameter."
     784              :               "\nEnvironment Variable Name: \"Different_String\""
     785              :             , 30
     786              :             , advgetopt::get_screen_width())
     787              : + advgetopt::format_usage_string(
     788              :               "--unique or -u"
     789              :             , "make sure everything is unique."
     790              :             , 30
     791              :             , advgetopt::get_screen_width())
     792              : + advgetopt::format_usage_string(
     793              :               "--validate"
     794              :             , "this is used to validate different things."
     795              :             , 30
     796              :             , advgetopt::get_screen_width())
     797              : + advgetopt::format_usage_string(
     798              :               "<default arguments>"
     799              :             , "other parameters are viewed as filenames."
     800              :             , 30
     801              :             , advgetopt::get_screen_width())
     802              : + footer
     803              :                         );
     804              : 
     805              :         // pretend an error occurred
     806              :         //
     807            1 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR),
     808              :   "Usage: try this one and we get a throw (valid options + usage calls)\n"
     809              :   "   --quiet or -q {<arg>}      make it quiet (opposite of verbose).\n"
     810              :   "   --validate                 this is used to validate different things.\n"
     811              : + footer
     812              :                         );
     813              : 
     814              :         // show GROUP1
     815              :         //
     816            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_GROUP1),
     817              :   advgetopt::breakup_line(
     818              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     819              :             , 0
     820              :             , advgetopt::get_screen_width())
     821              : + advgetopt::format_usage_string(
     822              :               "--not-specified-and-no-default <arg>"
     823              :             , "test long without having used the option and no default."
     824              :             , 30
     825              :             , advgetopt::get_screen_width())
     826              : + footer
     827              :                         );
     828              : 
     829              :         // show GROUP2
     830              :         //
     831            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_GROUP2),
     832              :   advgetopt::breakup_line(
     833              :               "Usage: try this one and we get a throw (valid options + usage calls)"
     834              :             , 0
     835              :             , advgetopt::get_screen_width())
     836              : + advgetopt::format_usage_string(
     837              :               "--not-specified-with-invalid-default <arg> {<arg>} (default is \"123abc\")"
     838              :             , "test that an invalid default value can be returned as is."
     839              :             , 30
     840              :             , advgetopt::get_screen_width())
     841              : + footer
     842              :                         );
     843            1 :     }
     844            4 :     CATCH_END_SECTION()
     845              : 
     846            4 :     CATCH_START_SECTION("usage_function: usage() using \"--filename\" for the default option accepting one required item")
     847              :     {
     848              :         // valid initialization + usage calls with a few different options
     849            1 :         const advgetopt::option options_list[] =
     850              :         {
     851              :             advgetopt::define_option(
     852              :                   advgetopt::Name("validate")
     853              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     854              :                 , advgetopt::Help("this is used to validate different things.")
     855              :             ),
     856              :             advgetopt::define_option(
     857              :                   advgetopt::Name("long")
     858              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_REQUIRED>())
     859              :                 , advgetopt::Help("used to validate that invalid numbers generate an error.")
     860              :             ),
     861              :             advgetopt::define_option(
     862              :                   advgetopt::Name("out-of-bounds")
     863              :                 , advgetopt::ShortName('o')
     864              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     865              :                 , advgetopt::Help("valid values from 1 to 9.")
     866              :             ),
     867              :             advgetopt::define_option(
     868              :                   advgetopt::Name("not-specified-and-no-default")
     869              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_SHOW_GROUP1>())
     870              :                 , advgetopt::Help("test long without having used the option and no default.")
     871              :             ),
     872              :             advgetopt::define_option(
     873              :                   advgetopt::Name("not-specified-with-invalid-default")
     874              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_MULTIPLE, advgetopt::GETOPT_FLAG_SHOW_GROUP2>())
     875              :                 , advgetopt::Help("test that an invalid default value can be returned as is.")
     876              :                 , advgetopt::DefaultValue("123abc")
     877              :             ),
     878              :             advgetopt::define_option(
     879              :                   advgetopt::Name("not-specified-string-without-default")
     880              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     881              :                 , advgetopt::Alias("string")
     882              :             ),
     883              :             advgetopt::define_option(
     884              :                   advgetopt::Name("string")
     885              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED>())
     886              :                 , advgetopt::Help("string parameter.")
     887              :             ),
     888              :             advgetopt::define_option(
     889              :                   advgetopt::Name("unique")
     890              :                 , advgetopt::ShortName('u')
     891              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
     892              :                 , advgetopt::Help("make sure everything is unique.")
     893              :             ),
     894              :             advgetopt::define_option(
     895              :                   advgetopt::Name("quiet")
     896              :                 , advgetopt::ShortName('q')
     897              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_MULTIPLE, advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     898              :                 , advgetopt::Help("make it quiet (opposite of verbose).")
     899              :             ),
     900              :             advgetopt::define_option(
     901              :                   advgetopt::Name("not-in-v2-though")
     902              :                 , advgetopt::ShortName('l')
     903              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE, advgetopt::GETOPT_FLAG_REQUIRED, advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
     904              :                 , advgetopt::Help("long with just a letter.")
     905              :             ),
     906              :             advgetopt::define_option(
     907              :                   advgetopt::Name("filename")
     908              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_DEFAULT_OPTION, advgetopt::GETOPT_FLAG_REQUIRED>())
     909              :                 , advgetopt::Help("other parameters are viewed as filenames; and we need at least one option with a very long help to check that it wraps perfectly (we'd really need to get the output of the command and check that against what is expected because at this time the test is rather blind in that respect! FIXED IN v2!)")
     910              :             ),
     911              :             advgetopt::end_options()
     912              :         };
     913              : 
     914            1 :         advgetopt::options_environment options;
     915            1 :         options.f_project_name = "unittest";
     916            1 :         options.f_options = options_list;
     917            1 :         options.f_help_header = "Usage: try this one and we get a throw (valid options + usage calls bis)";
     918            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
     919              : 
     920            1 :         char const * cargv2[] =
     921              :         {
     922              :             "tests/unittests/unittest_advgetopt",
     923              :             "--validate",
     924              :             "--long",
     925              :             "123abc",
     926              :             "--out-of-bounds",
     927              :             "123",
     928              :             "--string",
     929              :             "string value",
     930              :             nullptr
     931              :         };
     932            1 :         int const argc2 = sizeof(cargv2) / sizeof(cargv2[0]) - 1;
     933            1 :         char ** argv2 = const_cast<char **>(cargv2);
     934              : 
     935              :         // this initialization works as expected
     936            1 :         advgetopt::getopt opt(options, argc2, argv2);
     937              : 
     938              :         // all of the following have the exiting exception
     939              : //            for(int i(static_cast<int>(advgetopt::getopt::status_t::no_error)); i <= static_cast<int>(advgetopt::getopt::status_t::fatal); ++i)
     940              : //            {
     941              : //                CATCH_REQUIRE_THROWS_AS(opt.usage(static_cast<advgetopt::getopt::status_t>(i), "test no error, warnings, errors..."), advgetopt::getopt_exit);
     942              : //            }
     943           47 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_ALL),
     944              : advgetopt::breakup_line(
     945              :               "Usage: try this one and we get a throw (valid options + usage calls bis)"
     946              :             , 0
     947              :             , advgetopt::get_screen_width())
     948              : + advgetopt::format_usage_string(
     949              :               "--long <arg>"
     950              :             , "used to validate that invalid numbers generate an error."
     951              :             , 30
     952              :             , advgetopt::get_screen_width())
     953              : + advgetopt::format_usage_string(
     954              :               "--long-help or -?"
     955              :             , "show all the help from all the available options."
     956              :             , 30
     957              :             , advgetopt::get_screen_width())
     958              : + advgetopt::format_usage_string(
     959              :               "--not-in-v2-though or -l <arg>"
     960              :             , "long with just a letter."
     961              :             , 30
     962              :             , advgetopt::get_screen_width())
     963              : + advgetopt::format_usage_string(
     964              :               "--not-specified-and-no-default <arg>"
     965              :             , "test long without having used the option and no default."
     966              :             , 30
     967              :             , advgetopt::get_screen_width())
     968              : + advgetopt::format_usage_string(
     969              :               "--not-specified-with-invalid-default <arg> {<arg>} (default is \"123abc\")"
     970              :             , "test that an invalid default value can be returned as is."
     971              :             , 30
     972              :             , advgetopt::get_screen_width())
     973              : + advgetopt::format_usage_string(
     974              :               "--out-of-bounds or -o <arg>"
     975              :             , "valid values from 1 to 9."
     976              :             , 30
     977              :             , advgetopt::get_screen_width())
     978              : + advgetopt::format_usage_string(
     979              :               "--quiet or -q {<arg>}"
     980              :             , "make it quiet (opposite of verbose)."
     981              :             , 30
     982              :             , advgetopt::get_screen_width())
     983              : + advgetopt::format_usage_string(
     984              :               "--string or --not-specified-string-without-default <arg>"
     985              :             , "string parameter."
     986              :             , 30
     987              :             , advgetopt::get_screen_width())
     988              : + advgetopt::format_usage_string(
     989              :               "--unique or -u"
     990              :             , "make sure everything is unique."
     991              :             , 30
     992              :             , advgetopt::get_screen_width())
     993              : + advgetopt::format_usage_string(
     994              :               "--validate"
     995              :             , "this is used to validate different things."
     996              :             , 30
     997              :             , advgetopt::get_screen_width())
     998              : + advgetopt::format_usage_string(
     999              :               "<default argument>"
    1000              :             , "other parameters are viewed as filenames; and we"
    1001              :               " need at least one option with a very long help to"
    1002              :               " check that it wraps perfectly (we'd really need to"
    1003              :               " get the output of the command and check that"
    1004              :               " against what is expected because at this time the"
    1005              :               " test is rather blind in that respect! FIXED IN"
    1006              :               " v2!)"
    1007              :             , 30
    1008              :             , advgetopt::get_screen_width())
    1009              :                     );
    1010            1 :     }
    1011            4 :     CATCH_END_SECTION()
    1012              : 
    1013            4 :     CATCH_START_SECTION("usage_function: usage() using \"--\" for the default option accepting one item")
    1014              :     {
    1015              :         // valid initialization + usage calls with a few different options
    1016            1 :         const advgetopt::option options_list[] =
    1017              :         {
    1018              :             advgetopt::define_option(
    1019              :                   advgetopt::Name("validate")
    1020              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
    1021              :                 , advgetopt::Help("this is used to validate different things.")
    1022              :             ),
    1023              :             advgetopt::define_option(
    1024              :                   advgetopt::Name("long")
    1025              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_REQUIRED>())
    1026              :                 , advgetopt::Help("used to validate that invalid numbers generate an error.")
    1027              :             ),
    1028              :             advgetopt::define_option(
    1029              :                   advgetopt::Name("out-of-bounds")
    1030              :                 , advgetopt::ShortName('o')
    1031              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1032              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
    1033              :                 , advgetopt::Help("valid values from 1 to 9.")
    1034              :             ),
    1035              :             advgetopt::define_option(
    1036              :                   advgetopt::Name("not-specified-and-no-default")
    1037              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1038              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED
    1039              :                                                       , advgetopt::GETOPT_FLAG_SHOW_GROUP1>())
    1040              :                 , advgetopt::Help("test long without having used the option and no default.")
    1041              :             ),
    1042              :             advgetopt::define_option(
    1043              :                   advgetopt::Name("not-specified-with-invalid-default")
    1044              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1045              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED
    1046              :                                                       , advgetopt::GETOPT_FLAG_MULTIPLE
    1047              :                                                       , advgetopt::GETOPT_FLAG_SHOW_GROUP2>())
    1048              :                 , advgetopt::Help("test that an invalid default value can be returned as is.")
    1049              :                 , advgetopt::DefaultValue("123abc")
    1050              :             ),
    1051              :             advgetopt::define_option(
    1052              :                   advgetopt::Name("not-specified-string-without-default")
    1053              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1054              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
    1055              :                 , advgetopt::Alias("string")
    1056              :             ),
    1057              :             advgetopt::define_option(
    1058              :                   advgetopt::Name("string")
    1059              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1060              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED>())
    1061              :                 , advgetopt::Help("string parameter.")
    1062              :             ),
    1063              :             advgetopt::define_option(
    1064              :                   advgetopt::Name("unique")
    1065              :                 , advgetopt::ShortName('u')
    1066              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
    1067              :                 , advgetopt::Help("make sure everything is unique.")
    1068              :             ),
    1069              :             advgetopt::define_option(
    1070              :                   advgetopt::Name("quiet")
    1071              :                 , advgetopt::ShortName('q')
    1072              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1073              :                                                       , advgetopt::GETOPT_FLAG_MULTIPLE
    1074              :                                                       , advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
    1075              :                 , advgetopt::Help("make it quiet (opposite of verbose).")
    1076              :             ),
    1077              :             advgetopt::define_option(
    1078              :                   advgetopt::Name("option-argument")
    1079              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1080              :                                                       , advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
    1081              :                 , advgetopt::Help("command line option which accepts an optional argument.")
    1082              :             ),
    1083              :             advgetopt::define_option(
    1084              :                   advgetopt::Name("not-in-v2-though")
    1085              :                 , advgetopt::ShortName('l')
    1086              :                 , advgetopt::Flags(advgetopt::any_flags<advgetopt::GETOPT_FLAG_COMMAND_LINE
    1087              :                                                       , advgetopt::GETOPT_FLAG_REQUIRED
    1088              :                                                       , advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR>())
    1089              :                 , advgetopt::Help("long with just a letter.")
    1090              :             ),
    1091              :             advgetopt::define_option(
    1092              :                   advgetopt::Name("--")
    1093              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_DEFAULT_OPTION>())
    1094              :                 , advgetopt::Help("other parameters are viewed as filenames; and we need at least one option with a very long help to check that it wraps perfectly (we'd really need to get the output of the command and check that against what is expected because at this time the test is rather blind in that respect! FIXED IN v2!)")
    1095              :             ),
    1096              :             advgetopt::end_options()
    1097              :         };
    1098              : 
    1099            1 :         advgetopt::options_environment options;
    1100            1 :         options.f_project_name = "unittest";
    1101            1 :         options.f_options = options_list;
    1102            1 :         options.f_help_header = "Usage: %p try this one and we get a throw (valid options + usage calls bis)";
    1103            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1104              : 
    1105            1 :         char const * cargv2[] =
    1106              :         {
    1107              :             "tests/unittests/unittest_advgetopt",
    1108              :             "--validate",
    1109              :             "--long",
    1110              :             "123abc",
    1111              :             "--out-of-bounds",
    1112              :             "123",
    1113              :             "--string",
    1114              :             "string value",
    1115              :             nullptr
    1116              :         };
    1117            1 :         int const argc2 = sizeof(cargv2) / sizeof(cargv2[0]) - 1;
    1118            1 :         char ** argv2 = const_cast<char **>(cargv2);
    1119              : 
    1120              :         // this initialization works as expected
    1121            1 :         advgetopt::getopt opt(options, argc2, argv2);
    1122              : 
    1123              :         // all of the following have the exiting exception
    1124              : //            for(int i(static_cast<int>(advgetopt::getopt::status_t::no_error)); i <= static_cast<int>(advgetopt::getopt::status_t::fatal); ++i)
    1125              : //            {
    1126              : //                CATCH_REQUIRE_THROWS_AS(opt.usage(static_cast<advgetopt::getopt::status_t>(i), "test no error, warnings, errors..."), advgetopt::getopt_exit);
    1127              : //            }
    1128           51 :         CATCH_REQUIRE_LONG_STRING(opt.usage(advgetopt::GETOPT_FLAG_SHOW_ALL),
    1129              : advgetopt::breakup_line(
    1130              :               "Usage: unittest_advgetopt try this one and we get a throw"
    1131              :               " (valid options + usage calls bis)"
    1132              :             , 0
    1133              :             , advgetopt::get_screen_width())
    1134              : + advgetopt::format_usage_string(
    1135              :               "--long <arg>"
    1136              :             , "used to validate that invalid numbers generate an error."
    1137              :             , 30
    1138              :             , advgetopt::get_screen_width())
    1139              : + advgetopt::format_usage_string(
    1140              :               "--long-help or -?"
    1141              :             , "show all the help from all the available options."
    1142              :             , 30
    1143              :             , advgetopt::get_screen_width())
    1144              : + advgetopt::format_usage_string(
    1145              :               "--not-in-v2-though or -l <arg>"
    1146              :             , "long with just a letter."
    1147              :             , 30
    1148              :             , advgetopt::get_screen_width())
    1149              : + advgetopt::format_usage_string(
    1150              :               "--not-specified-and-no-default <arg>"
    1151              :             , "test long without having used the option and no default."
    1152              :             , 30
    1153              :             , advgetopt::get_screen_width())
    1154              : + advgetopt::format_usage_string(
    1155              :               "--not-specified-with-invalid-default <arg> {<arg>} (default is \"123abc\")"
    1156              :             , "test that an invalid default value can be returned as is."
    1157              :             , 30
    1158              :             , advgetopt::get_screen_width())
    1159              : + advgetopt::format_usage_string(
    1160              :               "--option-argument [<arg>]"
    1161              :             , "command line option which accepts an optional argument."
    1162              :             , 30
    1163              :             , advgetopt::get_screen_width())
    1164              : + advgetopt::format_usage_string(
    1165              :               "--out-of-bounds or -o <arg>"
    1166              :             , "valid values from 1 to 9."
    1167              :             , 30
    1168              :             , advgetopt::get_screen_width())
    1169              : + advgetopt::format_usage_string(
    1170              :               "--quiet or -q {<arg>}"
    1171              :             , "make it quiet (opposite of verbose)."
    1172              :             , 30
    1173              :             , advgetopt::get_screen_width())
    1174              : + advgetopt::format_usage_string(
    1175              :               "--string or --not-specified-string-without-default <arg>"
    1176              :             , "string parameter."
    1177              :             , 30
    1178              :             , advgetopt::get_screen_width())
    1179              : + advgetopt::format_usage_string(
    1180              :               "--unique or -u"
    1181              :             , "make sure everything is unique."
    1182              :             , 30
    1183              :             , advgetopt::get_screen_width())
    1184              : + advgetopt::format_usage_string(
    1185              :               "--validate"
    1186              :             , "this is used to validate different things."
    1187              :             , 30
    1188              :             , advgetopt::get_screen_width())
    1189              : + advgetopt::format_usage_string(
    1190              :               "[default argument]"
    1191              :             , "other parameters are viewed as filenames; and we need at least"
    1192              :               " one option with a very long help to check that it wraps"
    1193              :               " perfectly (we'd really need to get the output of the command"
    1194              :               " and check that against what is expected because at this time"
    1195              :               " the test is rather blind in that respect! FIXED IN v2!)"
    1196              :             , 30
    1197              :             , advgetopt::get_screen_width())
    1198              :                     );
    1199            1 :     }
    1200            4 :     CATCH_END_SECTION()
    1201            8 : }
    1202              : 
    1203              : 
    1204              : 
    1205              : 
    1206              : 
    1207            1 : CATCH_TEST_CASE("help_string_percent", "[getopt][usage]")
    1208              : {
    1209            1 :     CATCH_START_SECTION("help_string_percent: percent percent")
    1210              :     {
    1211            1 :         const advgetopt::option options_list[] =
    1212              :         {
    1213              :             advgetopt::define_option(
    1214              :                   advgetopt::Name("verbose")
    1215              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1216              :                 , advgetopt::Help("inform you of what we're currently working on: %%.")
    1217              :             ),
    1218              :             advgetopt::define_option(
    1219              :                   advgetopt::Name("this-is-a-very-long-argument-so-we-can-see-that-such-a-crazy-long-option-(who-does-that-though)-gets-broken-up-as-expected")
    1220              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1221              :                 , advgetopt::Help("I guess the help is not necessary now...")
    1222              :             ),
    1223              :             advgetopt::end_options()
    1224              :         };
    1225            1 :         char const * cargv[] =
    1226              :         {
    1227              :             "tests/unittests/usage",
    1228              :             "--verbose",
    1229              :             nullptr
    1230              :         };
    1231            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1232            1 :         char ** argv = const_cast<char **>(cargv);
    1233              : 
    1234            1 :         advgetopt::options_environment options;
    1235            1 :         options.f_project_name = "unittest";
    1236            1 :         options.f_options = options_list;
    1237            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1238            1 :         options.f_configuration_files = nullptr;
    1239            1 :         options.f_configuration_filename = "advgetopt.conf";
    1240            1 :         options.f_configuration_directories = nullptr;
    1241            1 :         options.f_help_header = "Usage: test usage: %%";
    1242            1 :         options.f_help_footer = "Percent Percent: %%";
    1243            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1244            1 :         options.f_version = "2.0.1-%%";
    1245            1 :         options.f_license = "MIT-%%";
    1246            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %%";
    1247            1 :         options.f_build_date = "Jun  4 2019 %%";
    1248            1 :         options.f_build_time = "23:02:36 %%";
    1249              : 
    1250            1 :         advgetopt::getopt opt(options, argc, argv);
    1251              : 
    1252            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1253           13 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1254              : advgetopt::breakup_line(
    1255              :               "Usage: test usage: %"
    1256              :             , 0
    1257              :             , advgetopt::get_screen_width())
    1258              : + advgetopt::format_usage_string(
    1259              :               "--this-is-a-very-long-argument-so-we-can-see-that-such-a-crazy-long-option-(who-does-that-though)-gets-broken-up-as-expected"
    1260              :             , "I guess the help is not necessary now..."
    1261              :             , 30
    1262              :             , advgetopt::get_screen_width())
    1263              : + advgetopt::format_usage_string(
    1264              :               "--verbose"
    1265              :             , "inform you of what we're currently working on: %."
    1266              :             , 30
    1267              :             , advgetopt::get_screen_width()) + "\n"
    1268              : + advgetopt::breakup_line(
    1269              :               "Percent Percent: %"
    1270              :             , 0
    1271              :             , advgetopt::get_screen_width())
    1272              :                 );
    1273              : 
    1274            1 :         CATCH_REQUIRE(opt.process_help_string(nullptr) == std::string());
    1275            1 :     }
    1276            1 :     CATCH_END_SECTION()
    1277            1 : }
    1278              : 
    1279              : 
    1280              : 
    1281              : 
    1282            3 : CATCH_TEST_CASE("help_string_project_name", "[getopt][usage]")
    1283              : {
    1284            3 :     CATCH_START_SECTION("help_string_project_name: percent project name (name defined)")
    1285              :     {
    1286            1 :         const advgetopt::option options_list[] =
    1287              :         {
    1288              :             advgetopt::define_option(
    1289              :                   advgetopt::Name("verbose")
    1290              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1291              :                 , advgetopt::Help("inform you of what we're currently working on: %a.")
    1292              :             ),
    1293              :             advgetopt::end_options()
    1294              :         };
    1295            1 :         char const * cargv[] =
    1296              :         {
    1297              :             "tests/unittests/usage",
    1298              :             "--verbose",
    1299              :             nullptr
    1300              :         };
    1301            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1302            1 :         char ** argv = const_cast<char **>(cargv);
    1303              : 
    1304            1 :         advgetopt::options_environment options;
    1305            1 :         options.f_project_name = "unittest";
    1306            1 :         options.f_options = options_list;
    1307            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1308            1 :         options.f_configuration_files = nullptr;
    1309            1 :         options.f_configuration_filename = "advgetopt.conf";
    1310            1 :         options.f_configuration_directories = nullptr;
    1311            1 :         options.f_help_header = "Usage: test usage: %a";
    1312            1 :         options.f_help_footer = "Percent Project Name: %a";
    1313            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1314            1 :         options.f_version = "2.0.1-%a";
    1315            1 :         options.f_license = "MIT-%a";
    1316            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %a";
    1317            1 :         options.f_build_date = "Jun  4 2019 %a";
    1318            1 :         options.f_build_time = "23:02:36 %a";
    1319              : 
    1320            1 :         advgetopt::getopt opt(options, argc, argv);
    1321              : 
    1322            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1323            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1324              : advgetopt::breakup_line(
    1325              :               "Usage: test usage: unittest"
    1326              :             , 0
    1327              :             , advgetopt::get_screen_width())
    1328              : + advgetopt::format_usage_string(
    1329              :               "--verbose"
    1330              :             , "inform you of what we're currently working on: unittest."
    1331              :             , 30
    1332              :             , advgetopt::get_screen_width()) + "\n"
    1333              : + advgetopt::breakup_line(
    1334              :               "Percent Project Name: unittest"
    1335              :             , 0
    1336              :             , advgetopt::get_screen_width())
    1337              :                 );
    1338            1 :     }
    1339            3 :     CATCH_END_SECTION()
    1340              : 
    1341            3 :     CATCH_START_SECTION("help_string_project_name: percent project name (nullptr)")
    1342              :     {
    1343            1 :         const advgetopt::option options_list[] =
    1344              :         {
    1345              :             advgetopt::define_option(
    1346              :                   advgetopt::Name("verbose")
    1347              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1348              :                 , advgetopt::Help("inform you of what we're currently working on: %a.")
    1349              :             ),
    1350              :             advgetopt::end_options()
    1351              :         };
    1352            1 :         char const * cargv[] =
    1353              :         {
    1354              :             "tests/unittests/usage",
    1355              :             "--verbose",
    1356              :             nullptr
    1357              :         };
    1358            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1359            1 :         char ** argv = const_cast<char **>(cargv);
    1360              : 
    1361            1 :         advgetopt::options_environment options;
    1362            1 :         options.f_project_name = nullptr;
    1363            1 :         options.f_options = options_list;
    1364            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1365            1 :         options.f_configuration_files = nullptr;
    1366            1 :         options.f_configuration_filename = "advgetopt.conf";
    1367            1 :         options.f_configuration_directories = nullptr;
    1368            1 :         options.f_help_header = "Usage: test usage: %a";
    1369            1 :         options.f_help_footer = "Percent Project Name: %a";
    1370            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1371            1 :         options.f_version = "2.0.1-%a";
    1372            1 :         options.f_license = "MIT-%a";
    1373            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %a";
    1374            1 :         options.f_build_date = "Jun  4 2019 %a";
    1375            1 :         options.f_build_time = "23:02:36 %a";
    1376              : 
    1377            1 :         advgetopt::getopt opt(options, argc, argv);
    1378              : 
    1379            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1380            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1381              : "Usage: test usage: %a\n"
    1382              : "   --verbose                  inform you of what we're currently working on: %a.\n"
    1383              : "\n"
    1384              : "Percent Project Name: %a\n"
    1385              :                 );
    1386            1 :     }
    1387            3 :     CATCH_END_SECTION()
    1388              : 
    1389            3 :     CATCH_START_SECTION("help_string_project_name: percent project name (\"\")")
    1390              :     {
    1391            1 :         const advgetopt::option options_list[] =
    1392              :         {
    1393              :             advgetopt::define_option(
    1394              :                   advgetopt::Name("verbose")
    1395              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1396              :                 , advgetopt::Help("inform you of what we're currently working on: %a.")
    1397              :             ),
    1398              :             advgetopt::end_options()
    1399              :         };
    1400            1 :         char const * cargv[] =
    1401              :         {
    1402              :             "tests/unittests/usage",
    1403              :             "--verbose",
    1404              :             nullptr
    1405              :         };
    1406            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1407            1 :         char ** argv = const_cast<char **>(cargv);
    1408              : 
    1409            1 :         advgetopt::options_environment options;
    1410            1 :         options.f_project_name = "";
    1411            1 :         options.f_options = options_list;
    1412            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1413            1 :         options.f_configuration_files = nullptr;
    1414            1 :         options.f_configuration_filename = "advgetopt.conf";
    1415            1 :         options.f_configuration_directories = nullptr;
    1416            1 :         options.f_help_header = "Usage: test usage: %a";
    1417            1 :         options.f_help_footer = "Percent Project Name: %a";
    1418            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1419            1 :         options.f_version = "2.0.1-%a";
    1420            1 :         options.f_license = "MIT-%a";
    1421            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %a";
    1422            1 :         options.f_build_date = "Jun  4 2019 %a";
    1423            1 :         options.f_build_time = "23:02:36 %a";
    1424              : 
    1425            1 :         advgetopt::getopt opt(options, argc, argv);
    1426              : 
    1427            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1428            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1429              : "Usage: test usage: \n"
    1430              : "   --verbose                  inform you of what we're currently working on: .\n"
    1431              : "\n"
    1432              : "Percent Project Name: \n"
    1433              :                 );
    1434            1 :     }
    1435            3 :     CATCH_END_SECTION()
    1436            3 : }
    1437              : 
    1438              : 
    1439              : 
    1440            3 : CATCH_TEST_CASE("help_string_build_date", "[getopt][usage]")
    1441              : {
    1442            3 :     CATCH_START_SECTION("help_string_build_date: percent build date (defined)")
    1443              :     {
    1444            1 :         const advgetopt::option options_list[] =
    1445              :         {
    1446              :             advgetopt::define_option(
    1447              :                   advgetopt::Name("verbose")
    1448              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1449              :                 , advgetopt::Help("inform you of what we're currently working on: %b.")
    1450              :             ),
    1451              :             advgetopt::end_options()
    1452              :         };
    1453            1 :         char const * cargv[] =
    1454              :         {
    1455              :             "tests/unittests/usage",
    1456              :             "--verbose",
    1457              :             nullptr
    1458              :         };
    1459            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1460            1 :         char ** argv = const_cast<char **>(cargv);
    1461              : 
    1462            1 :         advgetopt::options_environment options;
    1463            1 :         options.f_project_name = "unittest";
    1464            1 :         options.f_options = options_list;
    1465            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1466            1 :         options.f_configuration_files = nullptr;
    1467            1 :         options.f_configuration_filename = "advgetopt.conf";
    1468            1 :         options.f_configuration_directories = nullptr;
    1469            1 :         options.f_help_header = "Usage: test usage: %b";
    1470            1 :         options.f_help_footer = "Percent Build Date: %b";
    1471            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1472            1 :         options.f_version = "2.0.1-%b";
    1473            1 :         options.f_license = "MIT-%b";
    1474            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %b";
    1475            1 :         options.f_build_date = "Jun  4 2019 %b";
    1476            1 :         options.f_build_time = "23:02:36 %b";
    1477              : 
    1478            1 :         advgetopt::getopt opt(options, argc, argv);
    1479              : 
    1480            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1481            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1482              : advgetopt::breakup_line(
    1483              :               "Usage: test usage: Jun  4 2019 %b"
    1484              :             , 0
    1485              :             , advgetopt::get_screen_width())
    1486              : + advgetopt::format_usage_string(
    1487              :               "--verbose"
    1488              :             , "inform you of what we're currently working on: Jun  4 2019 %b."
    1489              :             , 30
    1490              :             , advgetopt::get_screen_width()) + "\n"
    1491              : + advgetopt::breakup_line(
    1492              :               "Percent Build Date: Jun  4 2019 %b"
    1493              :             , 0
    1494              :             , advgetopt::get_screen_width())
    1495              :                 );
    1496            1 :     }
    1497            3 :     CATCH_END_SECTION()
    1498              : 
    1499            3 :     CATCH_START_SECTION("help_string_build_date: percent build date (nullptr)")
    1500              :     {
    1501            1 :         const advgetopt::option options_list[] =
    1502              :         {
    1503              :             advgetopt::define_option(
    1504              :                   advgetopt::Name("verbose")
    1505              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1506              :                 , advgetopt::Help("inform you of what we're currently working on: %b.")
    1507              :             ),
    1508              :             advgetopt::end_options()
    1509              :         };
    1510            1 :         char const * cargv[] =
    1511              :         {
    1512              :             "tests/unittests/usage",
    1513              :             "--verbose",
    1514              :             nullptr
    1515              :         };
    1516            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1517            1 :         char ** argv = const_cast<char **>(cargv);
    1518              : 
    1519            1 :         advgetopt::options_environment options;
    1520            1 :         options.f_project_name = "unittest";
    1521            1 :         options.f_options = options_list;
    1522            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1523            1 :         options.f_configuration_files = nullptr;
    1524            1 :         options.f_configuration_filename = "advgetopt.conf";
    1525            1 :         options.f_configuration_directories = nullptr;
    1526            1 :         options.f_help_header = "Usage: test usage: %b";
    1527            1 :         options.f_help_footer = "Percent Build Date: %b";
    1528            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1529            1 :         options.f_version = "2.0.1-%b";
    1530            1 :         options.f_license = "MIT-%b";
    1531            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %b";
    1532            1 :         options.f_build_date = nullptr;
    1533            1 :         options.f_build_time = "23:02:36 %b";
    1534              : 
    1535            1 :         advgetopt::getopt opt(options, argc, argv);
    1536              : 
    1537            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1538            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1539              : "Usage: test usage: %b\n"
    1540              : "   --verbose                  inform you of what we're currently working on: %b.\n"
    1541              : "\n"
    1542              : "Percent Build Date: %b\n"
    1543              :                 );
    1544            1 :     }
    1545            3 :     CATCH_END_SECTION()
    1546              : 
    1547            3 :     CATCH_START_SECTION("help_string_build_date: percent build date (\"\")")
    1548              :     {
    1549            1 :         const advgetopt::option options_list[] =
    1550              :         {
    1551              :             advgetopt::define_option(
    1552              :                   advgetopt::Name("verbose")
    1553              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1554              :                 , advgetopt::Help("inform you of what we're currently working on: %b.")
    1555              :             ),
    1556              :             advgetopt::end_options()
    1557              :         };
    1558            1 :         char const * cargv[] =
    1559              :         {
    1560              :             "tests/unittests/usage",
    1561              :             "--verbose",
    1562              :             nullptr
    1563              :         };
    1564            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1565            1 :         char ** argv = const_cast<char **>(cargv);
    1566              : 
    1567            1 :         advgetopt::options_environment options;
    1568            1 :         options.f_project_name = "unittest";
    1569            1 :         options.f_options = options_list;
    1570            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1571            1 :         options.f_configuration_files = nullptr;
    1572            1 :         options.f_configuration_filename = "advgetopt.conf";
    1573            1 :         options.f_configuration_directories = nullptr;
    1574            1 :         options.f_help_header = "Usage: test usage: %b";
    1575            1 :         options.f_help_footer = "Percent Build Date: %b";
    1576            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1577            1 :         options.f_version = "2.0.1-%b";
    1578            1 :         options.f_license = "MIT-%b";
    1579            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %b";
    1580            1 :         options.f_build_date = "";
    1581            1 :         options.f_build_time = "23:02:36 %b";
    1582              : 
    1583            1 :         advgetopt::getopt opt(options, argc, argv);
    1584              : 
    1585            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1586            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1587              : "Usage: test usage: \n"
    1588              : "   --verbose                  inform you of what we're currently working on: .\n"
    1589              : "\n"
    1590              : "Percent Build Date: \n"
    1591              :                 );
    1592            1 :     }
    1593            3 :     CATCH_END_SECTION()
    1594            3 : }
    1595              : 
    1596              : 
    1597              : 
    1598              : 
    1599            3 : CATCH_TEST_CASE("help_string_copyright", "[getopt][usage]")
    1600              : {
    1601            3 :     CATCH_START_SECTION("help_string_copyright: percent copyright (defined)")
    1602              :     {
    1603            1 :         const advgetopt::option options_list[] =
    1604              :         {
    1605              :             advgetopt::define_option(
    1606              :                   advgetopt::Name("verbose")
    1607              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1608              :                 , advgetopt::Help("inform you of what we're currently working on: %c.")
    1609              :             ),
    1610              :             advgetopt::end_options()
    1611              :         };
    1612            1 :         char const * cargv[] =
    1613              :         {
    1614              :             "tests/unittests/usage",
    1615              :             "--verbose",
    1616              :             nullptr
    1617              :         };
    1618            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1619            1 :         char ** argv = const_cast<char **>(cargv);
    1620              : 
    1621            1 :         advgetopt::options_environment options;
    1622            1 :         options.f_project_name = "unittest";
    1623            1 :         options.f_options = options_list;
    1624            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1625            1 :         options.f_configuration_files = nullptr;
    1626            1 :         options.f_configuration_filename = "advgetopt.conf";
    1627            1 :         options.f_configuration_directories = nullptr;
    1628            1 :         options.f_help_header = "Usage: test usage: %c";
    1629            1 :         options.f_help_footer = "Percent Copyright: %c";
    1630            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1631            1 :         options.f_version = "2.0.1-%c";
    1632            1 :         options.f_license = "MIT-%c";
    1633            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %c";
    1634            1 :         options.f_build_date = "Jun  4 2019 %c";
    1635            1 :         options.f_build_time = "23:02:36 %c";
    1636              : 
    1637            1 :         advgetopt::getopt opt(options, argc, argv);
    1638              : 
    1639            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1640              : 
    1641              : //std::string a = opt.usage();
    1642              : //std::string b = "Usage: test usage: Copyright (c) 2019  Made to Order Software Corp. -- All\n"
    1643              : //"Rights Reserved %c\n"
    1644              : //"   --verbose                  inform you of what we're currently working on:\n"
    1645              : //"                              Copyright (c) 2019  Made to Order Software Corp.\n"
    1646              : //"                              -- All Rights Reserved %c.\n"
    1647              : //"\n"
    1648              : //"Percent Copyright: Copyright (c) 2019  Made to Order Software Corp. -- All\n"
    1649              : //"Rights Reserved %c\n";
    1650              : //int max(std::min(a.length(), b.length()));
    1651              : //for(int idx(0); idx < max;++idx)
    1652              : //{
    1653              : //    std::cerr << "[" << a[idx] << "] == [" << b[idx] << "] = " << (a[idx] == b[idx] ? "TRUE" : "FALSE") << "\n";
    1654              : //}
    1655              : 
    1656            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1657              : advgetopt::breakup_line(
    1658              :               "Usage: test usage: Copyright (c) 2019  Made to Order Software Corp. -- All"
    1659              :               " Rights Reserved %c"
    1660              :             , 0
    1661              :             , advgetopt::get_screen_width())
    1662              : + advgetopt::format_usage_string(
    1663              :               "--verbose"
    1664              :             , "inform you of what we're currently working on:"
    1665              :               " Copyright (c) 2019  Made to Order Software Corp."
    1666              :               " -- All Rights Reserved %c."
    1667              :             , 30
    1668              :             , advgetopt::get_screen_width()) + "\n"
    1669              : + advgetopt::breakup_line(
    1670              :               "Percent Copyright: Copyright (c) 2019  Made to Order Software"
    1671              :               " Corp. -- All Rights Reserved %c"
    1672              :             , 0
    1673              :             , advgetopt::get_screen_width())
    1674              :                 );
    1675            1 :     }
    1676            3 :     CATCH_END_SECTION()
    1677              : 
    1678            3 :     CATCH_START_SECTION("help_string_copyright: percent copyright (nullptr)")
    1679              :     {
    1680            1 :         const advgetopt::option options_list[] =
    1681              :         {
    1682              :             advgetopt::define_option(
    1683              :                   advgetopt::Name("verbose")
    1684              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1685              :                 , advgetopt::Help("inform you of what we're currently working on: %c.")
    1686              :             ),
    1687              :             advgetopt::end_options()
    1688              :         };
    1689            1 :         char const * cargv[] =
    1690              :         {
    1691              :             "tests/unittests/usage",
    1692              :             "--verbose",
    1693              :             nullptr
    1694              :         };
    1695            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1696            1 :         char ** argv = const_cast<char **>(cargv);
    1697              : 
    1698            1 :         advgetopt::options_environment options;
    1699            1 :         options.f_project_name = "unittest";
    1700            1 :         options.f_options = options_list;
    1701            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1702            1 :         options.f_configuration_files = nullptr;
    1703            1 :         options.f_configuration_filename = "advgetopt.conf";
    1704            1 :         options.f_configuration_directories = nullptr;
    1705            1 :         options.f_help_header = "Usage: test usage: %c";
    1706            1 :         options.f_help_footer = "Percent Copyright: %c";
    1707            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1708            1 :         options.f_version = "2.0.1-%c";
    1709            1 :         options.f_license = "MIT-%c";
    1710            1 :         options.f_copyright = nullptr;
    1711            1 :         options.f_build_date = "Jun  4 2019 %c";
    1712            1 :         options.f_build_time = "23:02:36 %c";
    1713              : 
    1714            1 :         advgetopt::getopt opt(options, argc, argv);
    1715              : 
    1716            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1717            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1718              : "Usage: test usage: %c\n"
    1719              : "   --verbose                  inform you of what we're currently working on: %c.\n"
    1720              : "\n"
    1721              : "Percent Copyright: %c\n"
    1722              :                 );
    1723            1 :     }
    1724            3 :     CATCH_END_SECTION()
    1725              : 
    1726            3 :     CATCH_START_SECTION("help_string_copyright: percent copyright (\"\")")
    1727              :     {
    1728            1 :         const advgetopt::option options_list[] =
    1729              :         {
    1730              :             advgetopt::define_option(
    1731              :                   advgetopt::Name("verbose")
    1732              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1733              :                 , advgetopt::Help("inform you of what we're currently working on: %c.")
    1734              :             ),
    1735              :             advgetopt::end_options()
    1736              :         };
    1737            1 :         char const * cargv[] =
    1738              :         {
    1739              :             "tests/unittests/usage",
    1740              :             "--verbose",
    1741              :             nullptr
    1742              :         };
    1743            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1744            1 :         char ** argv = const_cast<char **>(cargv);
    1745              : 
    1746            1 :         advgetopt::options_environment options;
    1747            1 :         options.f_project_name = "unittest";
    1748            1 :         options.f_options = options_list;
    1749            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1750            1 :         options.f_configuration_files = nullptr;
    1751            1 :         options.f_configuration_filename = "advgetopt.conf";
    1752            1 :         options.f_configuration_directories = nullptr;
    1753            1 :         options.f_help_header = "Usage: test usage: %c";
    1754            1 :         options.f_help_footer = "Percent Copyright: %c";
    1755            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1756            1 :         options.f_version = "2.0.1-%c";
    1757            1 :         options.f_license = "MIT-%c";
    1758            1 :         options.f_copyright = "";
    1759            1 :         options.f_build_date = "Jun  4 2019 %c";
    1760            1 :         options.f_build_time = "23:02:36 %c";
    1761              : 
    1762            1 :         advgetopt::getopt opt(options, argc, argv);
    1763              : 
    1764            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1765            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1766              : "Usage: test usage: \n"
    1767              : "   --verbose                  inform you of what we're currently working on: .\n"
    1768              : "\n"
    1769              : "Percent Copyright: \n"
    1770              :                 );
    1771            1 :     }
    1772            3 :     CATCH_END_SECTION()
    1773            3 : }
    1774              : 
    1775              : 
    1776              : 
    1777              : 
    1778            6 : CATCH_TEST_CASE("help_string_directories", "[getopt][usage][config]")
    1779              : {
    1780            6 :     CATCH_START_SECTION("help_string_copyright: percent directories (fully defined)")
    1781              :     {
    1782            1 :         const advgetopt::option options_list[] =
    1783              :         {
    1784              :             advgetopt::define_option(
    1785              :                   advgetopt::Name("verbose")
    1786              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1787              :                 , advgetopt::Help("inform you of what we're currently working on: %d.")
    1788              :             ),
    1789              :             advgetopt::end_options()
    1790              :         };
    1791            1 :         char const * cargv[] =
    1792              :         {
    1793              :             "tests/unittests/usage",
    1794              :             "--verbose",
    1795              :             nullptr
    1796              :         };
    1797            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1798            1 :         char ** argv = const_cast<char **>(cargv);
    1799              : 
    1800            1 :         const char * const configuration_directories[] =
    1801              :         {
    1802              :             "/etc/sys/advgetopt",
    1803              :             "/etc/advgetopt",
    1804              :             "/etc/advgetopt/advgetopt.d",
    1805              :             "~/.config/advgetopt",
    1806              :             nullptr
    1807              :         };
    1808              : 
    1809            1 :         advgetopt::options_environment options;
    1810            1 :         options.f_project_name = "unittest";
    1811            1 :         options.f_options = options_list;
    1812            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1813            1 :         options.f_configuration_files = nullptr;
    1814            1 :         options.f_configuration_filename = "advgetopt.conf";
    1815            1 :         options.f_configuration_directories = configuration_directories;
    1816            1 :         options.f_help_header = "Usage: test usage: %d";
    1817            1 :         options.f_help_footer = "Percent Directories: %d";
    1818            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1819            1 :         options.f_version = "2.0.1-%d";
    1820            1 :         options.f_license = "MIT-%d";
    1821            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %d";
    1822            1 :         options.f_build_date = "Jun  4 2019 %d";
    1823            1 :         options.f_build_time = "23:02:36 %d";
    1824              : 
    1825            1 :         advgetopt::getopt opt(options, argc, argv);
    1826              : 
    1827            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1828              : 
    1829            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1830              : advgetopt::breakup_line(
    1831              :               "Usage: test usage: /etc/sys/advgetopt"
    1832              :             , 0
    1833              :             , advgetopt::get_screen_width())
    1834              : + advgetopt::format_usage_string(
    1835              :               "--verbose"
    1836              :             , "inform you of what we're currently working on:"
    1837              :               " /etc/sys/advgetopt."
    1838              :             , 30
    1839              :             , advgetopt::get_screen_width()) + "\n"
    1840              : + advgetopt::breakup_line(
    1841              :               "Percent Directories: /etc/sys/advgetopt"
    1842              :             , 0
    1843              :             , advgetopt::get_screen_width())
    1844              :                 );
    1845            1 :     }
    1846            6 :     CATCH_END_SECTION()
    1847              : 
    1848            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk directories (fully defined)")
    1849              :     {
    1850            1 :         const advgetopt::option options_list[] =
    1851              :         {
    1852              :             advgetopt::define_option(
    1853              :                   advgetopt::Name("verbose")
    1854              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1855              :                 , advgetopt::Help("inform you of what we're currently working on: %*d.")
    1856              :             ),
    1857              :             advgetopt::end_options()
    1858              :         };
    1859            1 :         char const * cargv[] =
    1860              :         {
    1861              :             "tests/unittests/usage",
    1862              :             "--verbose",
    1863              :             nullptr
    1864              :         };
    1865            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1866            1 :         char ** argv = const_cast<char **>(cargv);
    1867              : 
    1868            1 :         const char * const configuration_directories[] =
    1869              :         {
    1870              :             "/etc/sys/advgetopt",
    1871              :             "/etc/advgetopt",
    1872              :             "/etc/advgetopt/advgetopt.d",
    1873              :             "~/.config/advgetopt",
    1874              :             nullptr
    1875              :         };
    1876              : 
    1877            1 :         advgetopt::options_environment options;
    1878            1 :         options.f_project_name = "unittest";
    1879            1 :         options.f_options = options_list;
    1880            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1881            1 :         options.f_configuration_files = nullptr;
    1882            1 :         options.f_configuration_filename = "advgetopt.conf";
    1883            1 :         options.f_configuration_directories = configuration_directories;
    1884            1 :         options.f_help_header = "Usage: test usage: %*d";
    1885            1 :         options.f_help_footer = "Percent Directories: %*d";
    1886            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1887            1 :         options.f_version = "2.0.1-%*d";
    1888            1 :         options.f_license = "MIT-%*d";
    1889            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*d";
    1890            1 :         options.f_build_date = "Jun  4 2019 %*d";
    1891            1 :         options.f_build_time = "23:02:36 %*d";
    1892              : 
    1893            1 :         advgetopt::getopt opt(options, argc, argv);
    1894              : 
    1895            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1896              : 
    1897            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1898              : advgetopt::breakup_line(
    1899              :               "Usage: test usage: /etc/sys/advgetopt, /etc/advgetopt,"
    1900              :               " /etc/advgetopt/advgetopt.d, ~/.config/advgetopt"
    1901              :             , 0
    1902              :             , advgetopt::get_screen_width())
    1903              : + advgetopt::format_usage_string(
    1904              :               "--verbose"
    1905              :             , "inform you of what we're currently working on:"
    1906              :               " /etc/sys/advgetopt, /etc/advgetopt,"
    1907              :               " /etc/advgetopt/advgetopt.d, ~/.config/advgetopt."
    1908              :             , 30
    1909              :             , advgetopt::get_screen_width()) + "\n"
    1910              : + advgetopt::breakup_line(
    1911              :               "Percent Directories: /etc/sys/advgetopt, /etc/advgetopt,"
    1912              :               " /etc/advgetopt/advgetopt.d, ~/.config/advgetopt"
    1913              :             , 0
    1914              :             , advgetopt::get_screen_width())
    1915              :                 );
    1916            1 :     }
    1917            6 :     CATCH_END_SECTION()
    1918              : 
    1919            6 :     CATCH_START_SECTION("help_string_copyright: percent directories (nullptr)")
    1920              :     {
    1921            1 :         const advgetopt::option options_list[] =
    1922              :         {
    1923              :             advgetopt::define_option(
    1924              :                   advgetopt::Name("verbose")
    1925              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1926              :                 , advgetopt::Help("inform you of what we're currently working on: %d.")
    1927              :             ),
    1928              :             advgetopt::end_options()
    1929              :         };
    1930            1 :         char const * cargv[] =
    1931              :         {
    1932              :             "tests/unittests/usage",
    1933              :             "--verbose",
    1934              :             nullptr
    1935              :         };
    1936            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1937            1 :         char ** argv = const_cast<char **>(cargv);
    1938              : 
    1939            1 :         advgetopt::options_environment options;
    1940            1 :         options.f_project_name = "unittest";
    1941            1 :         options.f_options = options_list;
    1942            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1943            1 :         options.f_configuration_files = nullptr;
    1944            1 :         options.f_configuration_filename = "advgetopt.conf";
    1945            1 :         options.f_configuration_directories = nullptr;
    1946            1 :         options.f_help_header = "Usage: test usage: %d";
    1947            1 :         options.f_help_footer = "Percent Directories: %d";
    1948            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1949            1 :         options.f_version = "2.0.1-%d";
    1950            1 :         options.f_license = "MIT-%d";
    1951            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %d";
    1952            1 :         options.f_build_date = "Jun  4 2019 %d";
    1953            1 :         options.f_build_time = "23:02:36 %d";
    1954              : 
    1955            1 :         advgetopt::getopt opt(options, argc, argv);
    1956              : 
    1957            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    1958            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    1959              : "Usage: test usage: %d\n"
    1960              : "   --verbose                  inform you of what we're currently working on: %d.\n"
    1961              : "\n"
    1962              : "Percent Directories: %d\n"
    1963              :                 );
    1964            1 :     }
    1965            6 :     CATCH_END_SECTION()
    1966              : 
    1967            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk directories (nullptr)")
    1968              :     {
    1969            1 :         const advgetopt::option options_list[] =
    1970              :         {
    1971              :             advgetopt::define_option(
    1972              :                   advgetopt::Name("verbose")
    1973              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    1974              :                 , advgetopt::Help("inform you of what we're currently working on: %*d.")
    1975              :             ),
    1976              :             advgetopt::end_options()
    1977              :         };
    1978            1 :         char const * cargv[] =
    1979              :         {
    1980              :             "tests/unittests/usage",
    1981              :             "--verbose",
    1982              :             nullptr
    1983              :         };
    1984            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    1985            1 :         char ** argv = const_cast<char **>(cargv);
    1986              : 
    1987            1 :         advgetopt::options_environment options;
    1988            1 :         options.f_project_name = "unittest";
    1989            1 :         options.f_options = options_list;
    1990            1 :         options.f_options_files_directory = "/etc/advgetopt";
    1991            1 :         options.f_configuration_files = nullptr;
    1992            1 :         options.f_configuration_filename = "advgetopt.conf";
    1993            1 :         options.f_configuration_directories = nullptr;
    1994            1 :         options.f_help_header = "Usage: test usage: %*d";
    1995            1 :         options.f_help_footer = "Percent Directories: %*d";
    1996            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    1997            1 :         options.f_version = "2.0.1-%*d";
    1998            1 :         options.f_license = "MIT-%*d";
    1999            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*d";
    2000            1 :         options.f_build_date = "Jun  4 2019 %*d";
    2001            1 :         options.f_build_time = "23:02:36 %*d";
    2002              : 
    2003            1 :         advgetopt::getopt opt(options, argc, argv);
    2004              : 
    2005            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2006            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2007              :   "Usage: test usage: %*d\n"
    2008              : + advgetopt::format_usage_string(
    2009              :               "--verbose"
    2010              :             , "inform you of what we're currently working on: %*d.\n"
    2011              :             , 30
    2012              :             , advgetopt::get_screen_width()) + "\n"
    2013              : + "Percent Directories: %*d\n"
    2014              :                 );
    2015            1 :     }
    2016            6 :     CATCH_END_SECTION()
    2017              : 
    2018            6 :     CATCH_START_SECTION("help_string_copyright: percent directories (empty array)")
    2019              :     {
    2020            1 :         const advgetopt::option options_list[] =
    2021              :         {
    2022              :             advgetopt::define_option(
    2023              :                   advgetopt::Name("verbose")
    2024              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    2025              :                 , advgetopt::Help("inform you of what we're currently working on: %d.")
    2026              :             ),
    2027              :             advgetopt::end_options()
    2028              :         };
    2029            1 :         char const * cargv[] =
    2030              :         {
    2031              :             "tests/unittests/usage",
    2032              :             "--verbose",
    2033              :             nullptr
    2034              :         };
    2035            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2036            1 :         char ** argv = const_cast<char **>(cargv);
    2037              : 
    2038            1 :         const char * const configuration_directories[] =
    2039              :         {
    2040              :             nullptr
    2041              :         };
    2042              : 
    2043            1 :         advgetopt::options_environment options;
    2044            1 :         options.f_project_name = "unittest";
    2045            1 :         options.f_options = options_list;
    2046            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2047            1 :         options.f_configuration_files = nullptr;
    2048            1 :         options.f_configuration_filename = "advgetopt.conf";
    2049            1 :         options.f_configuration_directories = configuration_directories;
    2050            1 :         options.f_help_header = "Usage: test usage: %d";
    2051            1 :         options.f_help_footer = "Percent Directories: %d";
    2052            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2053            1 :         options.f_version = "2.0.1-%d";
    2054            1 :         options.f_license = "MIT-%d";
    2055            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %d";
    2056            1 :         options.f_build_date = "Jun  4 2019 %d";
    2057            1 :         options.f_build_time = "23:02:36 %d";
    2058              : 
    2059            1 :         advgetopt::getopt opt(options, argc, argv);
    2060              : 
    2061            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2062            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2063              : "Usage: test usage: %d\n"
    2064              : "   --verbose                  inform you of what we're currently working on: %d.\n"
    2065              : "\n"
    2066              : "Percent Directories: %d\n"
    2067              :                 );
    2068            1 :     }
    2069            6 :     CATCH_END_SECTION()
    2070              : 
    2071            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk directories (empty array)")
    2072              :     {
    2073            1 :         const advgetopt::option options_list[] =
    2074              :         {
    2075              :             advgetopt::define_option(
    2076              :                   advgetopt::Name("verbose")
    2077              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    2078              :                 , advgetopt::Help("inform you of what we're currently working on: %*d.")
    2079              :             ),
    2080              :             advgetopt::end_options()
    2081              :         };
    2082            1 :         char const * cargv[] =
    2083              :         {
    2084              :             "tests/unittests/usage",
    2085              :             "--verbose",
    2086              :             nullptr
    2087              :         };
    2088            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2089            1 :         char ** argv = const_cast<char **>(cargv);
    2090              : 
    2091            1 :         const char * const configuration_directories[] =
    2092              :         {
    2093              :             nullptr
    2094              :         };
    2095              : 
    2096            1 :         advgetopt::options_environment options;
    2097            1 :         options.f_project_name = "unittest";
    2098            1 :         options.f_options = options_list;
    2099            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2100            1 :         options.f_configuration_files = nullptr;
    2101            1 :         options.f_configuration_filename = "advgetopt.conf";
    2102            1 :         options.f_configuration_directories = configuration_directories;
    2103            1 :         options.f_help_header = "Usage: test usage: %*d";
    2104            1 :         options.f_help_footer = "Percent Directories: %*d";
    2105            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2106            1 :         options.f_version = "2.0.1-%*d";
    2107            1 :         options.f_license = "MIT-%*d";
    2108            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*d";
    2109            1 :         options.f_build_date = "Jun  4 2019 %*d";
    2110            1 :         options.f_build_time = "23:02:36 %*d";
    2111              : 
    2112            1 :         advgetopt::getopt opt(options, argc, argv);
    2113              : 
    2114            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2115            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2116              :   "Usage: test usage: %*d\n"
    2117              : + advgetopt::format_usage_string(
    2118              :               "--verbose"
    2119              :             , "inform you of what we're currently working on: %*d.\n"
    2120              :             , 30
    2121              :             , advgetopt::get_screen_width()) + "\n"
    2122              : + "Percent Directories: %*d\n"
    2123              :                 );
    2124            1 :     }
    2125            6 :     CATCH_END_SECTION()
    2126            6 : }
    2127              : 
    2128              : 
    2129              : 
    2130              : 
    2131           13 : CATCH_TEST_CASE("help_string_environment_variable", "[getopt][usage]")
    2132              : {
    2133           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (fully defined, variable set)")
    2134              :     {
    2135            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2136              : 
    2137            1 :         const advgetopt::option options_list[] =
    2138              :         {
    2139              :             advgetopt::define_option(
    2140              :                   advgetopt::Name("verbose")
    2141              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2142              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2143              :             ),
    2144              :             advgetopt::end_options()
    2145              :         };
    2146            1 :         char const * cargv[] =
    2147              :         {
    2148              :             "tests/unittests/usage",
    2149              :             nullptr
    2150              :         };
    2151            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2152            1 :         char ** argv = const_cast<char **>(cargv);
    2153              : 
    2154            1 :         advgetopt::options_environment options;
    2155            1 :         options.f_project_name = "unittest";
    2156            1 :         options.f_options = options_list;
    2157            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2158            1 :         options.f_configuration_files = nullptr;
    2159            1 :         options.f_configuration_filename = "advgetopt.conf";
    2160            1 :         options.f_configuration_directories = nullptr;
    2161            1 :         options.f_help_header = "Usage: test usage: %e";
    2162            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2163            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2164            1 :         options.f_version = "2.0.1-%e";
    2165            1 :         options.f_license = "MIT-%e";
    2166            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2167            1 :         options.f_build_date = "Jun  4 2019 %e";
    2168            1 :         options.f_build_time = "23:02:36 %e";
    2169              : 
    2170            1 :         advgetopt::getopt opt(options, argc, argv);
    2171              : 
    2172            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2173              : 
    2174            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2175              : advgetopt::breakup_line(
    2176              :               "Usage: test usage: ADVGETOPT_TEST_OPTIONS"
    2177              :             , 0
    2178              :             , advgetopt::get_screen_width())
    2179              : + advgetopt::format_usage_string(
    2180              :               "--verbose"
    2181              :             , "inform you of what we're currently working on:"
    2182              :               " ADVGETOPT_TEST_OPTIONS."
    2183              :             , 30
    2184              :             , advgetopt::get_screen_width()) + "\n"
    2185              : + advgetopt::breakup_line(
    2186              :               "Percent Environment Variable: ADVGETOPT_TEST_OPTIONS"
    2187              :             , 0
    2188              :             , advgetopt::get_screen_width())
    2189              :                 );
    2190            1 :     }
    2191           13 :     CATCH_END_SECTION()
    2192              : 
    2193           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (fully defined, variable not set)")
    2194              :     {
    2195            1 :         const advgetopt::option options_list[] =
    2196              :         {
    2197              :             advgetopt::define_option(
    2198              :                   advgetopt::Name("verbose")
    2199              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2200              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2201              :             ),
    2202              :             advgetopt::end_options()
    2203              :         };
    2204            1 :         char const * cargv[] =
    2205              :         {
    2206              :             "tests/unittests/usage",
    2207              :             nullptr
    2208              :         };
    2209            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2210            1 :         char ** argv = const_cast<char **>(cargv);
    2211              : 
    2212            1 :         advgetopt::options_environment options;
    2213            1 :         options.f_project_name = "unittest";
    2214            1 :         options.f_options = options_list;
    2215            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2216            1 :         options.f_configuration_files = nullptr;
    2217            1 :         options.f_configuration_filename = "advgetopt.conf";
    2218            1 :         options.f_configuration_directories = nullptr;
    2219            1 :         options.f_help_header = "Usage: test usage: %e";
    2220            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2221            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2222            1 :         options.f_version = "2.0.1-%e";
    2223            1 :         options.f_license = "MIT-%e";
    2224            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2225            1 :         options.f_build_date = "Jun  4 2019 %e";
    2226            1 :         options.f_build_time = "23:02:36 %e";
    2227              : 
    2228            1 :         advgetopt::getopt opt(options, argc, argv);
    2229              : 
    2230            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2231              : 
    2232            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2233              : advgetopt::breakup_line(
    2234              :               "Usage: test usage: ADVGETOPT_TEST_OPTIONS"
    2235              :             , 0
    2236              :             , advgetopt::get_screen_width())
    2237              : + advgetopt::format_usage_string(
    2238              :               "--verbose"
    2239              :             , "inform you of what we're currently working on:"
    2240              :               " ADVGETOPT_TEST_OPTIONS."
    2241              :             , 30
    2242              :             , advgetopt::get_screen_width()) + "\n"
    2243              : + advgetopt::breakup_line(
    2244              :               "Percent Environment Variable: ADVGETOPT_TEST_OPTIONS"
    2245              :             , 0
    2246              :             , advgetopt::get_screen_width())
    2247              :                 );
    2248            1 :     }
    2249           13 :     CATCH_END_SECTION()
    2250              : 
    2251           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (fully defined, variable set)")
    2252              :     {
    2253            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2254              : 
    2255            1 :         const advgetopt::option options_list[] =
    2256              :         {
    2257              :             advgetopt::define_option(
    2258              :                   advgetopt::Name("verbose")
    2259              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2260              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2261              :             ),
    2262              :             advgetopt::end_options()
    2263              :         };
    2264            1 :         char const * cargv[] =
    2265              :         {
    2266              :             "tests/unittests/usage",
    2267              :             nullptr
    2268              :         };
    2269            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2270            1 :         char ** argv = const_cast<char **>(cargv);
    2271              : 
    2272            1 :         advgetopt::options_environment options;
    2273            1 :         options.f_project_name = "unittest";
    2274            1 :         options.f_options = options_list;
    2275            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2276            1 :         options.f_configuration_files = nullptr;
    2277            1 :         options.f_configuration_filename = "advgetopt.conf";
    2278            1 :         options.f_configuration_directories = nullptr;
    2279            1 :         options.f_help_header = "Usage: test usage: %*e";
    2280            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2281            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2282            1 :         options.f_version = "2.0.1-%*e";
    2283            1 :         options.f_license = "MIT-%*e";
    2284            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2285            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2286            1 :         options.f_build_time = "23:02:36 %*e";
    2287              : 
    2288            1 :         advgetopt::getopt opt(options, argc, argv);
    2289              : 
    2290            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2291              : 
    2292            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2293              : advgetopt::breakup_line(
    2294              :               "Usage: test usage: ADVGETOPT_TEST_OPTIONS=--verbose"
    2295              :             , 0
    2296              :             , advgetopt::get_screen_width())
    2297              : + advgetopt::format_usage_string(
    2298              :               "--verbose"
    2299              :             , "inform you of what we're currently working on:"
    2300              :               " ADVGETOPT_TEST_OPTIONS=--verbose."
    2301              :             , 30
    2302              :             , advgetopt::get_screen_width()) + "\n"
    2303              : + advgetopt::breakup_line(
    2304              :               "Percent Environment Variable: ADVGETOPT_TEST_OPTIONS=--verbose"
    2305              :             , 0
    2306              :             , advgetopt::get_screen_width())
    2307              :                 );
    2308            1 :     }
    2309           13 :     CATCH_END_SECTION()
    2310              : 
    2311           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (fully defined, variable not set)")
    2312              :     {
    2313            1 :         const advgetopt::option options_list[] =
    2314              :         {
    2315              :             advgetopt::define_option(
    2316              :                   advgetopt::Name("verbose")
    2317              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2318              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2319              :             ),
    2320              :             advgetopt::end_options()
    2321              :         };
    2322            1 :         char const * cargv[] =
    2323              :         {
    2324              :             "tests/unittests/usage",
    2325              :             nullptr
    2326              :         };
    2327            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2328            1 :         char ** argv = const_cast<char **>(cargv);
    2329              : 
    2330            1 :         advgetopt::options_environment options;
    2331            1 :         options.f_project_name = "unittest";
    2332            1 :         options.f_options = options_list;
    2333            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2334            1 :         options.f_configuration_files = nullptr;
    2335            1 :         options.f_configuration_filename = "advgetopt.conf";
    2336            1 :         options.f_configuration_directories = nullptr;
    2337            1 :         options.f_help_header = "Usage: test usage: %*e";
    2338            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2339            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2340            1 :         options.f_version = "2.0.1-%*e";
    2341            1 :         options.f_license = "MIT-%*e";
    2342            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2343            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2344            1 :         options.f_build_time = "23:02:36 %*e";
    2345              : 
    2346            1 :         advgetopt::getopt opt(options, argc, argv);
    2347              : 
    2348            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2349              : 
    2350            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2351              : advgetopt::breakup_line(
    2352              :               "Usage: test usage: ADVGETOPT_TEST_OPTIONS (not set)"
    2353              :             , 0
    2354              :             , advgetopt::get_screen_width())
    2355              : + advgetopt::format_usage_string(
    2356              :               "--verbose"
    2357              :             , "inform you of what we're currently working on:"
    2358              :               " ADVGETOPT_TEST_OPTIONS (not set)."
    2359              :             , 30
    2360              :             , advgetopt::get_screen_width()) + "\n"
    2361              : + advgetopt::breakup_line(
    2362              :               "Percent Environment Variable: ADVGETOPT_TEST_OPTIONS (not set)"
    2363              :             , 0
    2364              :             , advgetopt::get_screen_width())
    2365              :                 );
    2366            1 :     }
    2367           13 :     CATCH_END_SECTION()
    2368              : 
    2369           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (nullptr, variable set)")
    2370              :     {
    2371            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2372              : 
    2373            1 :         const advgetopt::option options_list[] =
    2374              :         {
    2375              :             advgetopt::define_option(
    2376              :                   advgetopt::Name("verbose")
    2377              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2378              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2379              :             ),
    2380              :             advgetopt::end_options()
    2381              :         };
    2382            1 :         char const * cargv[] =
    2383              :         {
    2384              :             "tests/unittests/usage",
    2385              :             nullptr
    2386              :         };
    2387            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2388            1 :         char ** argv = const_cast<char **>(cargv);
    2389              : 
    2390            1 :         advgetopt::options_environment options;
    2391            1 :         options.f_project_name = "unittest";
    2392            1 :         options.f_options = options_list;
    2393            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2394            1 :         options.f_configuration_files = nullptr;
    2395            1 :         options.f_configuration_filename = "advgetopt.conf";
    2396            1 :         options.f_configuration_directories = nullptr;
    2397            1 :         options.f_help_header = "Usage: test usage: %e";
    2398            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2399            1 :         options.f_environment_variable_name = nullptr;
    2400            1 :         options.f_version = "2.0.1-%e";
    2401            1 :         options.f_license = "MIT-%e";
    2402            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2403            1 :         options.f_build_date = "Jun  4 2019 %e";
    2404            1 :         options.f_build_time = "23:02:36 %e";
    2405              : 
    2406            1 :         advgetopt::getopt opt(options, argc, argv);
    2407              : 
    2408            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2409            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2410              :   "Usage: test usage: %e\n"
    2411              : + advgetopt::format_usage_string(
    2412              :               "--verbose"
    2413              :             , "inform you of what we're currently working on: %e.\n"
    2414              :             , 30
    2415              :             , advgetopt::get_screen_width()) + "\n"
    2416              : + "Percent Environment Variable: %e\n"
    2417              :                 );
    2418            1 :     }
    2419           13 :     CATCH_END_SECTION()
    2420              : 
    2421           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (nullptr, variable not set)")
    2422              :     {
    2423            1 :         const advgetopt::option options_list[] =
    2424              :         {
    2425              :             advgetopt::define_option(
    2426              :                   advgetopt::Name("verbose")
    2427              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2428              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2429              :             ),
    2430              :             advgetopt::end_options()
    2431              :         };
    2432            1 :         char const * cargv[] =
    2433              :         {
    2434              :             "tests/unittests/usage",
    2435              :             nullptr
    2436              :         };
    2437            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2438            1 :         char ** argv = const_cast<char **>(cargv);
    2439              : 
    2440            1 :         advgetopt::options_environment options;
    2441            1 :         options.f_project_name = "unittest";
    2442            1 :         options.f_options = options_list;
    2443            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2444            1 :         options.f_configuration_files = nullptr;
    2445            1 :         options.f_configuration_filename = "advgetopt.conf";
    2446            1 :         options.f_configuration_directories = nullptr;
    2447            1 :         options.f_help_header = "Usage: test usage: %e";
    2448            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2449            1 :         options.f_environment_variable_name = nullptr;
    2450            1 :         options.f_version = "2.0.1-%e";
    2451            1 :         options.f_license = "MIT-%e";
    2452            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2453            1 :         options.f_build_date = "Jun  4 2019 %e";
    2454            1 :         options.f_build_time = "23:02:36 %e";
    2455              : 
    2456            1 :         advgetopt::getopt opt(options, argc, argv);
    2457              : 
    2458            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2459            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2460              : "Usage: test usage: %e\n"
    2461              : "   --verbose                  inform you of what we're currently working on: %e.\n"
    2462              : "\n"
    2463              : "Percent Environment Variable: %e\n"
    2464              :                 );
    2465            1 :     }
    2466           13 :     CATCH_END_SECTION()
    2467              : 
    2468           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (nullptr, variable set)")
    2469              :     {
    2470            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2471              : 
    2472            1 :         const advgetopt::option options_list[] =
    2473              :         {
    2474              :             advgetopt::define_option(
    2475              :                   advgetopt::Name("verbose")
    2476              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2477              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2478              :             ),
    2479              :             advgetopt::end_options()
    2480              :         };
    2481            1 :         char const * cargv[] =
    2482              :         {
    2483              :             "tests/unittests/usage",
    2484              :             nullptr
    2485              :         };
    2486            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2487            1 :         char ** argv = const_cast<char **>(cargv);
    2488              : 
    2489            1 :         advgetopt::options_environment options;
    2490            1 :         options.f_project_name = "unittest";
    2491            1 :         options.f_options = options_list;
    2492            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2493            1 :         options.f_configuration_files = nullptr;
    2494            1 :         options.f_configuration_filename = "advgetopt.conf";
    2495            1 :         options.f_configuration_directories = nullptr;
    2496            1 :         options.f_help_header = "Usage: test usage: %*e";
    2497            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2498            1 :         options.f_environment_variable_name = nullptr;
    2499            1 :         options.f_version = "2.0.1-%*e";
    2500            1 :         options.f_license = "MIT-%*e";
    2501            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2502            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2503            1 :         options.f_build_time = "23:02:36 %*e";
    2504              : 
    2505            1 :         advgetopt::getopt opt(options, argc, argv);
    2506              : 
    2507            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2508            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2509              :   "Usage: test usage: %*e\n"
    2510              : + advgetopt::format_usage_string(
    2511              :               "--verbose"
    2512              :             , "inform you of what we're currently working on: %*e.\n"
    2513              :             , 30
    2514              :             , advgetopt::get_screen_width()) + "\n"
    2515              : + "Percent Environment Variable: %*e\n"
    2516              :                 );
    2517            1 :     }
    2518           13 :     CATCH_END_SECTION()
    2519              : 
    2520           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (nullptr, variable not set)")
    2521              :     {
    2522            1 :         const advgetopt::option options_list[] =
    2523              :         {
    2524              :             advgetopt::define_option(
    2525              :                   advgetopt::Name("verbose")
    2526              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2527              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2528              :             ),
    2529              :             advgetopt::end_options()
    2530              :         };
    2531            1 :         char const * cargv[] =
    2532              :         {
    2533              :             "tests/unittests/usage",
    2534              :             nullptr
    2535              :         };
    2536            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2537            1 :         char ** argv = const_cast<char **>(cargv);
    2538              : 
    2539            1 :         advgetopt::options_environment options;
    2540            1 :         options.f_project_name = "unittest";
    2541            1 :         options.f_options = options_list;
    2542            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2543            1 :         options.f_configuration_files = nullptr;
    2544            1 :         options.f_configuration_filename = "advgetopt.conf";
    2545            1 :         options.f_configuration_directories = nullptr;
    2546            1 :         options.f_help_header = "Usage: test usage: %*e";
    2547            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2548            1 :         options.f_environment_variable_name = nullptr;
    2549            1 :         options.f_version = "2.0.1-%*e";
    2550            1 :         options.f_license = "MIT-%*e";
    2551            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2552            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2553            1 :         options.f_build_time = "23:02:36 %*e";
    2554              : 
    2555            1 :         advgetopt::getopt opt(options, argc, argv);
    2556              : 
    2557            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2558            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2559              :   "Usage: test usage: %*e\n"
    2560              : + advgetopt::format_usage_string(
    2561              :               "--verbose"
    2562              :             , "inform you of what we're currently working on: %*e.\n"
    2563              :             , 30
    2564              :             , advgetopt::get_screen_width()) + "\n"
    2565              : "Percent Environment Variable: %*e\n"
    2566              :                 );
    2567            1 :     }
    2568           13 :     CATCH_END_SECTION()
    2569              : 
    2570           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (empty string, variable set)")
    2571              :     {
    2572            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2573              : 
    2574            1 :         const advgetopt::option options_list[] =
    2575              :         {
    2576              :             advgetopt::define_option(
    2577              :                   advgetopt::Name("verbose")
    2578              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2579              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2580              :             ),
    2581              :             advgetopt::end_options()
    2582              :         };
    2583            1 :         char const * cargv[] =
    2584              :         {
    2585              :             "tests/unittests/usage",
    2586              :             nullptr
    2587              :         };
    2588            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2589            1 :         char ** argv = const_cast<char **>(cargv);
    2590              : 
    2591              : 
    2592            1 :         advgetopt::options_environment options;
    2593            1 :         options.f_project_name = "unittest";
    2594            1 :         options.f_options = options_list;
    2595            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2596            1 :         options.f_configuration_files = nullptr;
    2597            1 :         options.f_configuration_filename = "advgetopt.conf";
    2598            1 :         options.f_configuration_directories = nullptr;
    2599            1 :         options.f_help_header = "Usage: test usage: %e";
    2600            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2601            1 :         options.f_environment_variable_name = "";
    2602            1 :         options.f_version = "2.0.1-%e";
    2603            1 :         options.f_license = "MIT-%e";
    2604            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2605            1 :         options.f_build_date = "Jun  4 2019 %e";
    2606            1 :         options.f_build_time = "23:02:36 %e";
    2607              : 
    2608            1 :         advgetopt::getopt opt(options, argc, argv);
    2609              : 
    2610            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2611            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2612              : "Usage: test usage: %e\n"
    2613              : "   --verbose                  inform you of what we're currently working on: %e.\n"
    2614              : "\n"
    2615              : "Percent Environment Variable: %e\n"
    2616              :                 );
    2617            1 :     }
    2618           13 :     CATCH_END_SECTION()
    2619              : 
    2620           13 :     CATCH_START_SECTION("help_string_copyright: percent environment variable (empty string, variable not set)")
    2621              :     {
    2622            1 :         const advgetopt::option options_list[] =
    2623              :         {
    2624              :             advgetopt::define_option(
    2625              :                   advgetopt::Name("verbose")
    2626              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2627              :                 , advgetopt::Help("inform you of what we're currently working on: %e.")
    2628              :             ),
    2629              :             advgetopt::end_options()
    2630              :         };
    2631            1 :         char const * cargv[] =
    2632              :         {
    2633              :             "tests/unittests/usage",
    2634              :             nullptr
    2635              :         };
    2636            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2637            1 :         char ** argv = const_cast<char **>(cargv);
    2638              : 
    2639              : 
    2640            1 :         advgetopt::options_environment options;
    2641            1 :         options.f_project_name = "unittest";
    2642            1 :         options.f_options = options_list;
    2643            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2644            1 :         options.f_configuration_files = nullptr;
    2645            1 :         options.f_configuration_filename = "advgetopt.conf";
    2646            1 :         options.f_configuration_directories = nullptr;
    2647            1 :         options.f_help_header = "Usage: test usage: %e";
    2648            1 :         options.f_help_footer = "Percent Environment Variable: %e";
    2649            1 :         options.f_environment_variable_name = "";
    2650            1 :         options.f_version = "2.0.1-%e";
    2651            1 :         options.f_license = "MIT-%e";
    2652            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %e";
    2653            1 :         options.f_build_date = "Jun  4 2019 %e";
    2654            1 :         options.f_build_time = "23:02:36 %e";
    2655              : 
    2656            1 :         advgetopt::getopt opt(options, argc, argv);
    2657              : 
    2658            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2659            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2660              : "Usage: test usage: %e\n"
    2661              : "   --verbose                  inform you of what we're currently working on: %e.\n"
    2662              : "\n"
    2663              : "Percent Environment Variable: %e\n"
    2664              :                 );
    2665            1 :     }
    2666           13 :     CATCH_END_SECTION()
    2667              : 
    2668           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (empty string, variable set)")
    2669              :     {
    2670            5 :         snapdev::safe_setenv env("ADVGETOPT_TEST_OPTIONS", "--verbose");
    2671              : 
    2672            1 :         const advgetopt::option options_list[] =
    2673              :         {
    2674              :             advgetopt::define_option(
    2675              :                   advgetopt::Name("verbose")
    2676              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2677              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2678              :             ),
    2679              :             advgetopt::end_options()
    2680              :         };
    2681            1 :         char const * cargv[] =
    2682              :         {
    2683              :             "tests/unittests/usage",
    2684              :             nullptr
    2685              :         };
    2686            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2687            1 :         char ** argv = const_cast<char **>(cargv);
    2688              : 
    2689            1 :         advgetopt::options_environment options;
    2690            1 :         options.f_project_name = "unittest";
    2691            1 :         options.f_options = options_list;
    2692            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2693            1 :         options.f_configuration_files = nullptr;
    2694            1 :         options.f_configuration_filename = "advgetopt.conf";
    2695            1 :         options.f_configuration_directories = nullptr;
    2696            1 :         options.f_help_header = "Usage: test usage: %*e";
    2697            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2698            1 :         options.f_environment_variable_name = "";
    2699            1 :         options.f_version = "2.0.1-%*e";
    2700            1 :         options.f_license = "MIT-%*e";
    2701            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2702            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2703            1 :         options.f_build_time = "23:02:36 %*e";
    2704              : 
    2705            1 :         advgetopt::getopt opt(options, argc, argv);
    2706              : 
    2707            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2708            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2709              :   "Usage: test usage: %*e\n"
    2710              : + advgetopt::format_usage_string(
    2711              :               "--verbose"
    2712              :             , "inform you of what we're currently working on: %*e.\n"
    2713              :             , 30
    2714              :             , advgetopt::get_screen_width()) + "\n"
    2715              : + "Percent Environment Variable: %*e\n"
    2716              :                 );
    2717            1 :     }
    2718           13 :     CATCH_END_SECTION()
    2719              : 
    2720           13 :     CATCH_START_SECTION("help_string_copyright: percent asterisk environment variable (empty string, variable not set)")
    2721              :     {
    2722            1 :         const advgetopt::option options_list[] =
    2723              :         {
    2724              :             advgetopt::define_option(
    2725              :                   advgetopt::Name("verbose")
    2726              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2727              :                 , advgetopt::Help("inform you of what we're currently working on: %*e.")
    2728              :             ),
    2729              :             advgetopt::end_options()
    2730              :         };
    2731            1 :         char const * cargv[] =
    2732              :         {
    2733              :             "tests/unittests/usage",
    2734              :             nullptr
    2735              :         };
    2736            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2737            1 :         char ** argv = const_cast<char **>(cargv);
    2738              : 
    2739            1 :         advgetopt::options_environment options;
    2740            1 :         options.f_project_name = "unittest";
    2741            1 :         options.f_options = options_list;
    2742            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2743            1 :         options.f_configuration_files = nullptr;
    2744            1 :         options.f_configuration_filename = "advgetopt.conf";
    2745            1 :         options.f_configuration_directories = nullptr;
    2746            1 :         options.f_help_header = "Usage: test usage: %*e";
    2747            1 :         options.f_help_footer = "Percent Environment Variable: %*e";
    2748            1 :         options.f_environment_variable_name = "";
    2749            1 :         options.f_version = "2.0.1-%*e";
    2750            1 :         options.f_license = "MIT-%*e";
    2751            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*e";
    2752            1 :         options.f_build_date = "Jun  4 2019 %*e";
    2753            1 :         options.f_build_time = "23:02:36 %*e";
    2754              : 
    2755            1 :         advgetopt::getopt opt(options, argc, argv);
    2756              : 
    2757            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2758            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2759              :   "Usage: test usage: %*e\n"
    2760              : + advgetopt::format_usage_string(
    2761              :               "--verbose"
    2762              :             , "inform you of what we're currently working on: %*e.\n"
    2763              :             , 30
    2764              :             , advgetopt::get_screen_width()) + "\n"
    2765              : + "Percent Environment Variable: %*e\n"
    2766              :                 );
    2767            1 :     }
    2768           13 :     CATCH_END_SECTION()
    2769              : 
    2770           13 :     CATCH_START_SECTION("help_string_copyright: environment variable intro (undefined)")
    2771              :     {
    2772            1 :         const advgetopt::option options_list[] =
    2773              :         {
    2774              :             advgetopt::define_option(
    2775              :                   advgetopt::Name("verbose")
    2776              :                 , advgetopt::Flags(advgetopt::var_flags<advgetopt::GETOPT_FLAG_FLAG>())
    2777              :                 , advgetopt::Help("inform you of what we're currently working on: %E.")
    2778              :             ),
    2779              :             advgetopt::end_options()
    2780              :         };
    2781            1 :         char const * cargv[] =
    2782              :         {
    2783              :             "tests/unittests/usage",
    2784              :             nullptr
    2785              :         };
    2786            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2787            1 :         char ** argv = const_cast<char **>(cargv);
    2788              : 
    2789            1 :         advgetopt::options_environment options;
    2790            1 :         options.f_project_name = "unittest";
    2791            1 :         options.f_options = options_list;
    2792            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2793            1 :         options.f_configuration_files = nullptr;
    2794            1 :         options.f_configuration_filename = "advgetopt.conf";
    2795            1 :         options.f_configuration_directories = nullptr;
    2796            1 :         options.f_help_header = "Usage: test usage: %E";
    2797            1 :         options.f_help_footer = "Percent Environment Variable: %E";
    2798            1 :         options.f_version = "2.0.1-%E";
    2799            1 :         options.f_license = "MIT-%E";
    2800            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %E";
    2801            1 :         options.f_build_date = "Jun  4 2019 %E";
    2802            1 :         options.f_build_time = "23:02:36 %E";
    2803              : 
    2804            1 :         advgetopt::getopt opt(options, argc, argv);
    2805              : 
    2806            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2807              : 
    2808            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2809              :   advgetopt::breakup_line(
    2810              :               "Usage: test usage: %E"
    2811              :             , 0
    2812              :             , advgetopt::get_screen_width())
    2813              : + advgetopt::format_usage_string(
    2814              :               "--verbose"
    2815              :             , "inform you of what we're currently working on:"
    2816              :               " %E."
    2817              :             , 30
    2818              :             , advgetopt::get_screen_width()) + "\n"
    2819              : + advgetopt::breakup_line(
    2820              :               "Percent Environment Variable: %E"
    2821              :             , 0
    2822              :             , advgetopt::get_screen_width())
    2823              :                 );
    2824            1 :     }
    2825           13 :     CATCH_END_SECTION()
    2826              : 
    2827           13 : }
    2828              : 
    2829              : 
    2830              : 
    2831              : 
    2832              : 
    2833            6 : CATCH_TEST_CASE("help_string_configuration_files", "[getopt][usage][config]")
    2834              : {
    2835            6 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with f (fully defined)")
    2836              :     {
    2837            1 :         const advgetopt::option options_list[] =
    2838              :         {
    2839              :             advgetopt::define_option(
    2840              :                   advgetopt::Name("verbose")
    2841              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    2842              :                 , advgetopt::Help("inform you of what we're currently working on: %f.")
    2843              :             ),
    2844              :             advgetopt::end_options()
    2845              :         };
    2846            1 :         char const * cargv[] =
    2847              :         {
    2848              :             "tests/unittests/usage",
    2849              :             "--verbose",
    2850              :             nullptr
    2851              :         };
    2852            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2853            1 :         char ** argv = const_cast<char **>(cargv);
    2854              : 
    2855            1 :         const char * const configuration_files[] =
    2856              :         {
    2857              :             "system.conf",
    2858              :             "advgetopt.conf",
    2859              :             "advgetopt.ini",
    2860              :             "user.config",
    2861              :             nullptr
    2862              :         };
    2863              : 
    2864            1 :         advgetopt::options_environment options;
    2865            1 :         options.f_project_name = "unittest";
    2866            1 :         options.f_options = options_list;
    2867            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2868            1 :         options.f_configuration_files = configuration_files;
    2869            1 :         options.f_configuration_filename = "advgetopt.conf";
    2870            1 :         options.f_configuration_directories = nullptr;
    2871            1 :         options.f_help_header = "Usage: test usage: %f";
    2872            1 :         options.f_help_footer = "Percent Configuration Files: %f";
    2873            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2874            1 :         options.f_version = "2.0.1-%f";
    2875            1 :         options.f_license = "MIT-%f";
    2876            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %f";
    2877            1 :         options.f_build_date = "Jun  4 2019 %f";
    2878            1 :         options.f_build_time = "23:02:36 %f";
    2879              : 
    2880            1 :         advgetopt::getopt opt(options, argc, argv);
    2881              : 
    2882            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2883              : 
    2884            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2885              : advgetopt::breakup_line(
    2886              :               "Usage: test usage: system.conf"
    2887              :             , 0
    2888              :             , advgetopt::get_screen_width())
    2889              : + advgetopt::format_usage_string(
    2890              :               "--verbose"
    2891              :             , "inform you of what we're currently working on: system.conf."
    2892              :             , 30
    2893              :             , advgetopt::get_screen_width()) + "\n"
    2894              : + advgetopt::breakup_line(
    2895              :               "Percent Configuration Files: system.conf"
    2896              :             , 0
    2897              :             , advgetopt::get_screen_width())
    2898              :                 );
    2899            1 :     }
    2900            6 :     CATCH_END_SECTION()
    2901              : 
    2902            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with f (fully defined)")
    2903              :     {
    2904            1 :         const advgetopt::option options_list[] =
    2905              :         {
    2906              :             advgetopt::define_option(
    2907              :                   advgetopt::Name("verbose")
    2908              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    2909              :                 , advgetopt::Help("inform you of what we're currently working on: %*f.")
    2910              :             ),
    2911              :             advgetopt::end_options()
    2912              :         };
    2913            1 :         char const * cargv[] =
    2914              :         {
    2915              :             "tests/unittests/usage",
    2916              :             "--verbose",
    2917              :             nullptr
    2918              :         };
    2919            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2920            1 :         char ** argv = const_cast<char **>(cargv);
    2921              : 
    2922            1 :         const char * const configuration_files[] =
    2923              :         {
    2924              :             "system.conf",
    2925              :             "advgetopt.conf",
    2926              :             "advgetopt.ini",
    2927              :             "user.config",
    2928              :             nullptr
    2929              :         };
    2930              : 
    2931            1 :         advgetopt::options_environment options;
    2932            1 :         options.f_project_name = "unittest";
    2933            1 :         options.f_options = options_list;
    2934            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2935            1 :         options.f_configuration_files = configuration_files;
    2936            1 :         options.f_configuration_filename = "advgetopt.conf";
    2937            1 :         options.f_configuration_directories = nullptr;
    2938            1 :         options.f_help_header = "Usage: test usage: %*f";
    2939            1 :         options.f_help_footer = "Percent Configuration Files: %*f";
    2940            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    2941            1 :         options.f_version = "2.0.1-%*f";
    2942            1 :         options.f_license = "MIT-%*f";
    2943            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*f";
    2944            1 :         options.f_build_date = "Jun  4 2019 %*f";
    2945            1 :         options.f_build_time = "23:02:36 %*f";
    2946              : 
    2947            1 :         advgetopt::getopt opt(options, argc, argv);
    2948              : 
    2949            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    2950              : 
    2951            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    2952              : advgetopt::breakup_line(
    2953              :               "Usage: test usage: system.conf, advgetopt.conf,"
    2954              :               " advgetopt.ini, user.config"
    2955              :             , 0
    2956              :             , advgetopt::get_screen_width())
    2957              : + advgetopt::format_usage_string(
    2958              :               "--verbose"
    2959              :             , "inform you of what we're currently working on:"
    2960              :               " system.conf, advgetopt.conf, advgetopt.ini,"
    2961              :               " user.config."
    2962              :             , 30
    2963              :             , advgetopt::get_screen_width()) + "\n"
    2964              : + advgetopt::breakup_line(
    2965              :               "Percent Configuration Files: system.conf, advgetopt.conf,"
    2966              :               " advgetopt.ini, user.config"
    2967              :             , 0
    2968              :             , advgetopt::get_screen_width())
    2969              :                 );
    2970            1 :     }
    2971            6 :     CATCH_END_SECTION()
    2972              : 
    2973            6 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with f (nullptr)")
    2974              :     {
    2975            1 :         const advgetopt::option options_list[] =
    2976              :         {
    2977              :             advgetopt::define_option(
    2978              :                   advgetopt::Name("verbose")
    2979              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    2980              :                 , advgetopt::Help("inform you of what we're currently working on: %f.")
    2981              :             ),
    2982              :             advgetopt::end_options()
    2983              :         };
    2984            1 :         char const * cargv[] =
    2985              :         {
    2986              :             "tests/unittests/usage",
    2987              :             "--verbose",
    2988              :             nullptr
    2989              :         };
    2990            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    2991            1 :         char ** argv = const_cast<char **>(cargv);
    2992              : 
    2993            1 :         advgetopt::options_environment options;
    2994            1 :         options.f_project_name = "unittest";
    2995            1 :         options.f_options = options_list;
    2996            1 :         options.f_options_files_directory = "/etc/advgetopt";
    2997            1 :         options.f_configuration_files = nullptr;
    2998            1 :         options.f_configuration_filename = "advgetopt.conf";
    2999            1 :         options.f_configuration_directories = nullptr;
    3000            1 :         options.f_help_header = "Usage: test usage: %f";
    3001            1 :         options.f_help_footer = "Percent Configuration Files: %f";
    3002            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3003            1 :         options.f_version = "2.0.1-%f";
    3004            1 :         options.f_license = "MIT-%f";
    3005            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %f";
    3006            1 :         options.f_build_date = "Jun  4 2019 %f";
    3007            1 :         options.f_build_time = "23:02:36 %f";
    3008              : 
    3009            1 :         advgetopt::getopt opt(options, argc, argv);
    3010              : 
    3011            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3012            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3013              : "Usage: test usage: %f\n"
    3014              : "   --verbose                  inform you of what we're currently working on: %f.\n"
    3015              : "\n"
    3016              : "Percent Configuration Files: %f\n"
    3017              :                 );
    3018            1 :     }
    3019            6 :     CATCH_END_SECTION()
    3020              : 
    3021            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with f (nullptr)")
    3022              :     {
    3023            1 :         const advgetopt::option options_list[] =
    3024              :         {
    3025              :             advgetopt::define_option(
    3026              :                   advgetopt::Name("verbose")
    3027              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3028              :                 , advgetopt::Help("inform you of what we're currently working on: %*f.")
    3029              :             ),
    3030              :             advgetopt::end_options()
    3031              :         };
    3032            1 :         char const * cargv[] =
    3033              :         {
    3034              :             "tests/unittests/usage",
    3035              :             "--verbose",
    3036              :             nullptr
    3037              :         };
    3038            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3039            1 :         char ** argv = const_cast<char **>(cargv);
    3040              : 
    3041            1 :         advgetopt::options_environment options;
    3042            1 :         options.f_project_name = "unittest";
    3043            1 :         options.f_options = options_list;
    3044            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3045            1 :         options.f_configuration_files = nullptr;
    3046            1 :         options.f_configuration_filename = "advgetopt.conf";
    3047            1 :         options.f_configuration_directories = nullptr;
    3048            1 :         options.f_help_header = "Usage: test usage: %*f";
    3049            1 :         options.f_help_footer = "Percent Configuration Files: %*f";
    3050            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3051            1 :         options.f_version = "2.0.1-%*f";
    3052            1 :         options.f_license = "MIT-%*f";
    3053            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*f";
    3054            1 :         options.f_build_date = "Jun  4 2019 %*f";
    3055            1 :         options.f_build_time = "23:02:36 %*f";
    3056              : 
    3057            1 :         advgetopt::getopt opt(options, argc, argv);
    3058              : 
    3059            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3060            5 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3061              :   "Usage: test usage: %*f\n"
    3062              : + advgetopt::format_usage_string(
    3063              :               "--verbose"
    3064              :             , "inform you of what we're currently working on: %*f.\n"
    3065              :             , 30
    3066              :             , advgetopt::get_screen_width()) + "\n"
    3067              : + "Percent Configuration Files: %*f\n"
    3068              :                 );
    3069            1 :     }
    3070            6 :     CATCH_END_SECTION()
    3071              : 
    3072            6 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with f (empty array)")
    3073              :     {
    3074            1 :         const advgetopt::option options_list[] =
    3075              :         {
    3076              :             advgetopt::define_option(
    3077              :                   advgetopt::Name("verbose")
    3078              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3079              :                 , advgetopt::Help("inform you of what we're currently working on: %f.")
    3080              :             ),
    3081              :             advgetopt::end_options()
    3082              :         };
    3083            1 :         char const * cargv[] =
    3084              :         {
    3085              :             "tests/unittests/usage",
    3086              :             "--verbose",
    3087              :             nullptr
    3088              :         };
    3089            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3090            1 :         char ** argv = const_cast<char **>(cargv);
    3091              : 
    3092            1 :         const char * const configuration_files[] =
    3093              :         {
    3094              :             nullptr
    3095              :         };
    3096              : 
    3097            1 :         advgetopt::options_environment options;
    3098            1 :         options.f_project_name = "unittest";
    3099            1 :         options.f_options = options_list;
    3100            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3101            1 :         options.f_configuration_files = configuration_files;
    3102            1 :         options.f_configuration_filename = "advgetopt.conf";
    3103            1 :         options.f_configuration_directories = nullptr;
    3104            1 :         options.f_help_header = "Usage: test usage: %f";
    3105            1 :         options.f_help_footer = "Percent Configuration Files: %f";
    3106            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3107            1 :         options.f_version = "2.0.1-%f";
    3108            1 :         options.f_license = "MIT-%f";
    3109            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %f";
    3110            1 :         options.f_build_date = "Jun  4 2019 %f";
    3111            1 :         options.f_build_time = "23:02:36 %f";
    3112              : 
    3113            1 :         advgetopt::getopt opt(options, argc, argv);
    3114              : 
    3115            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3116            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3117              : "Usage: test usage: %f\n"
    3118              : "   --verbose                  inform you of what we're currently working on: %f.\n"
    3119              : "\n"
    3120              : "Percent Configuration Files: %f\n"
    3121              :                 );
    3122            1 :     }
    3123            6 :     CATCH_END_SECTION()
    3124              : 
    3125            6 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with f (empty array)")
    3126              :     {
    3127            1 :         const advgetopt::option options_list[] =
    3128              :         {
    3129              :             advgetopt::define_option(
    3130              :                   advgetopt::Name("verbose")
    3131              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3132              :                 , advgetopt::Help("inform you of what we're currently working on: %*f.")
    3133              :             ),
    3134              :             advgetopt::end_options()
    3135              :         };
    3136            1 :         char const * cargv[] =
    3137              :         {
    3138              :             "tests/unittests/usage",
    3139              :             "--verbose",
    3140              :             nullptr
    3141              :         };
    3142            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3143            1 :         char ** argv = const_cast<char **>(cargv);
    3144              : 
    3145            1 :         const char * const configuration_files[] =
    3146              :         {
    3147              :             nullptr
    3148              :         };
    3149              : 
    3150            1 :         advgetopt::options_environment options;
    3151            1 :         options.f_project_name = "unittest";
    3152            1 :         options.f_options = options_list;
    3153            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3154            1 :         options.f_configuration_files = configuration_files;
    3155            1 :         options.f_configuration_filename = "advgetopt.conf";
    3156            1 :         options.f_configuration_directories = nullptr;
    3157            1 :         options.f_help_header = "Usage: test usage: %*f";
    3158            1 :         options.f_help_footer = "Percent Configuration Files: %*f";
    3159            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3160            1 :         options.f_version = "2.0.1-%*f";
    3161            1 :         options.f_license = "MIT-%*f";
    3162            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*f";
    3163            1 :         options.f_build_date = "Jun  4 2019 %*f";
    3164            1 :         options.f_build_time = "23:02:36 %*f";
    3165              : 
    3166            1 :         advgetopt::getopt opt(options, argc, argv);
    3167              : 
    3168            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3169            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3170              : "Usage: test usage: %*f\n"
    3171              : "   --verbose                  inform you of what we're currently working on:\n"
    3172              : "                              %*f.\n"
    3173              : "\n"
    3174              : "Percent Configuration Files: %*f\n"
    3175              :                 );
    3176            1 :     }
    3177            6 :     CATCH_END_SECTION()
    3178            6 : }
    3179              : 
    3180              : 
    3181              : 
    3182              : 
    3183            7 : CATCH_TEST_CASE("help_string_configuration_files_functions", "[getopt][usage][config]")
    3184              : {
    3185            7 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with g (fully defined)")
    3186              :     {
    3187            5 :         SNAP_CATCH2_NAMESPACE::init_tmp_dir("config_filenames", "existing_g");
    3188              : 
    3189              :         {
    3190            1 :             std::ofstream config_file;
    3191            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    3192            1 :             CATCH_REQUIRE(config_file.good());
    3193              :             config_file <<
    3194            1 :                 "# Auto-generated\n"
    3195              :             ;
    3196            1 :         }
    3197              : 
    3198              :         {
    3199            1 :             std::ofstream config_file;
    3200            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_project_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    3201            1 :             CATCH_REQUIRE(config_file.good());
    3202              :             config_file <<
    3203            1 :                 "# Auto-generated\n"
    3204              :             ;
    3205            1 :         }
    3206              : 
    3207            1 :         const advgetopt::option options_list[] =
    3208              :         {
    3209              :             advgetopt::define_option(
    3210              :                   advgetopt::Name("verbose")
    3211              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3212              :                 , advgetopt::Help("inform you of what we're currently working on: %g.")
    3213              :             ),
    3214              :             advgetopt::end_options()
    3215              :         };
    3216            1 :         char const * cargv[] =
    3217              :         {
    3218              :             "tests/unittests/usage",
    3219              :             "--verbose",
    3220              :             nullptr
    3221              :         };
    3222            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3223            1 :         char ** argv = const_cast<char **>(cargv);
    3224              : 
    3225            1 :         const char * const configuration_files[] =
    3226              :         {
    3227              :             "system.conf",
    3228            1 :             SNAP_CATCH2_NAMESPACE::g_config_filename.c_str(),
    3229              :             "advgetopt.conf",
    3230              :             "advgetopt.ini",
    3231              :             "user.config",
    3232            1 :             SNAP_CATCH2_NAMESPACE::g_config_project_filename.c_str(),   // <- this is wrong, it should be done automatically, but we have a name mismatch...
    3233              :             nullptr
    3234            1 :         };
    3235              : 
    3236            1 :         advgetopt::options_environment options;
    3237            1 :         options.f_project_name = "unittest";        // name mismatch on purpose
    3238            1 :         options.f_options = options_list;
    3239            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3240            1 :         options.f_configuration_files = configuration_files;
    3241            1 :         options.f_configuration_filename = "advgetopt.conf";
    3242            1 :         options.f_configuration_directories = nullptr;
    3243            1 :         options.f_help_header = "Usage: test usage: %g";
    3244            1 :         options.f_help_footer = "Percent Configuration Files: %g";
    3245            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3246            1 :         options.f_version = "2.0.1-%g";
    3247            1 :         options.f_license = "MIT-%g";
    3248            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %g";
    3249            1 :         options.f_build_date = "Jun  4 2019 %g";
    3250            1 :         options.f_build_time = "23:02:36 %g";
    3251              : 
    3252            1 :         advgetopt::getopt opt(options, argc, argv);
    3253              : 
    3254            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3255              : 
    3256            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3257              : advgetopt::breakup_line(
    3258              :               "Usage: test usage: "
    3259              :             + SNAP_CATCH2_NAMESPACE::g_config_filename
    3260              :             + ", "
    3261              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    3262              :         , 0
    3263              :         , advgetopt::get_screen_width())
    3264              : + advgetopt::format_usage_string(
    3265              :               "--verbose", "inform you of what we're currently working on: "
    3266              :             + SNAP_CATCH2_NAMESPACE::g_config_filename + ", "
    3267              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename + "."
    3268              :         , 30
    3269              :         , advgetopt::get_screen_width()) + "\n"
    3270              : + advgetopt::breakup_line(
    3271              :               "Percent Configuration Files: "
    3272              :             + SNAP_CATCH2_NAMESPACE::g_config_filename
    3273              :             + ", "
    3274              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    3275              :         , 0
    3276              :         , advgetopt::get_screen_width())
    3277              :                 );
    3278            1 :     }
    3279            7 :     CATCH_END_SECTION()
    3280              : 
    3281            7 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with g (fully defined)")
    3282              :     {
    3283            5 :         SNAP_CATCH2_NAMESPACE::init_tmp_dir("config_file_names", "with_existing_g");
    3284              : 
    3285              :         {
    3286            1 :             std::ofstream config_file;
    3287            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    3288            1 :             CATCH_REQUIRE(config_file.good());
    3289              :             config_file <<
    3290            1 :                 "# Auto-generated\n"
    3291              :             ;
    3292            1 :         }
    3293              : 
    3294              :         {
    3295            1 :             std::ofstream config_file;
    3296            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_project_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    3297            1 :             CATCH_REQUIRE(config_file.good());
    3298              :             config_file <<
    3299            1 :                 "# Auto-generated\n"
    3300              :             ;
    3301            1 :         }
    3302              : 
    3303            1 :         const advgetopt::option options_list[] =
    3304              :         {
    3305              :             advgetopt::define_option(
    3306              :                   advgetopt::Name("verbose")
    3307              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3308              :                 , advgetopt::Help("inform you of what we're currently working on: %g.")
    3309              :             ),
    3310              :             advgetopt::end_options()
    3311              :         };
    3312            1 :         char const * cargv[] =
    3313              :         {
    3314              :             "tests/unittests/usage",
    3315              :             "--verbose",
    3316              :             nullptr
    3317              :         };
    3318            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3319            1 :         char ** argv = const_cast<char **>(cargv);
    3320              : 
    3321            1 :         const char * const configuration_files[] =
    3322              :         {
    3323              :             "system.conf",
    3324            1 :             SNAP_CATCH2_NAMESPACE::g_config_filename.c_str(),
    3325              :             "advgetopt.conf",
    3326              :             "advgetopt.ini",
    3327              :             "user.config",
    3328              :             nullptr
    3329            1 :         };
    3330              : 
    3331            1 :         advgetopt::options_environment options;
    3332            1 :         options.f_project_name = "config_file_names";
    3333            1 :         options.f_options = options_list;
    3334            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3335            1 :         options.f_configuration_files = configuration_files;
    3336            1 :         options.f_configuration_filename = "advgetopt.conf";
    3337            1 :         options.f_configuration_directories = nullptr;
    3338            1 :         options.f_help_header = "Usage: test usage: %g";
    3339            1 :         options.f_help_footer = "Percent Configuration Files: %g";
    3340            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3341            1 :         options.f_version = "2.0.1-%g";
    3342            1 :         options.f_license = "MIT-%g";
    3343            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %g";
    3344            1 :         options.f_build_date = "Jun  4 2019 %g";
    3345            1 :         options.f_build_time = "23:02:36 %g";
    3346              : 
    3347            1 :         advgetopt::getopt opt(options, argc, argv);
    3348              : 
    3349            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3350              : 
    3351            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3352              : advgetopt::breakup_line(
    3353              :               "Usage: test usage: "
    3354              :             + SNAP_CATCH2_NAMESPACE::g_config_filename
    3355              :             + ", "
    3356              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    3357              :         , 0
    3358              :         , advgetopt::get_screen_width())
    3359              : + advgetopt::format_usage_string(
    3360              :               "--verbose", "inform you of what we're currently working on: "
    3361              :             + SNAP_CATCH2_NAMESPACE::g_config_filename + ", "
    3362              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename + "."
    3363              :         , 30
    3364              :         , advgetopt::get_screen_width()) + "\n"
    3365              : + advgetopt::breakup_line(
    3366              :               "Percent Configuration Files: "
    3367              :             + SNAP_CATCH2_NAMESPACE::g_config_filename
    3368              :             + ", "
    3369              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    3370              :         , 0
    3371              :         , advgetopt::get_screen_width())
    3372              :                 );
    3373            1 :     }
    3374            7 :     CATCH_END_SECTION()
    3375              : 
    3376            7 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with g (fully defined)")
    3377              :     {
    3378            1 :         const advgetopt::option options_list[] =
    3379              :         {
    3380              :             advgetopt::define_option(
    3381              :                   advgetopt::Name("verbose")
    3382              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3383              :                 , advgetopt::Help("inform you of what we're currently working on: %*g.")
    3384              :             ),
    3385              :             advgetopt::end_options()
    3386              :         };
    3387            1 :         char const * cargv[] =
    3388              :         {
    3389              :             "tests/unittests/usage",
    3390              :             "--verbose",
    3391              :             nullptr
    3392              :         };
    3393            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3394            1 :         char ** argv = const_cast<char **>(cargv);
    3395              : 
    3396            1 :         const char * const configuration_files[] =
    3397              :         {
    3398              :             "system.conf",
    3399              :             "advgetopt.conf",
    3400              :             "advgetopt.ini",
    3401              :             "user.config",
    3402              :             nullptr
    3403              :         };
    3404              : 
    3405            1 :         advgetopt::options_environment options;
    3406            1 :         options.f_project_name = "unittest";
    3407            1 :         options.f_options = options_list;
    3408            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3409            1 :         options.f_configuration_files = configuration_files;
    3410            1 :         options.f_configuration_filename = "advgetopt.conf";
    3411            1 :         options.f_configuration_directories = nullptr;
    3412            1 :         options.f_help_header = "Usage: test usage: %*g";
    3413            1 :         options.f_help_footer = "Percent Configuration Files: %*g";
    3414            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3415            1 :         options.f_version = "2.0.1-%*g";
    3416            1 :         options.f_license = "MIT-%*g";
    3417            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*g";
    3418            1 :         options.f_build_date = "Jun  4 2019 %*g";
    3419            1 :         options.f_build_time = "23:02:36 %*g";
    3420              : 
    3421            1 :         advgetopt::getopt opt(options, argc, argv);
    3422              : 
    3423            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3424              : 
    3425            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3426              : advgetopt::breakup_line(
    3427              :           "Usage: test usage:"
    3428              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3429              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3430              :           " /usr/share/unittest/options/advgetopt.conf,"
    3431              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3432              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf,"
    3433              :           " system.conf, unittest.d/50-system.conf,"
    3434              :           " advgetopt.conf, unittest.d/50-advgetopt.conf, advgetopt.ini,"
    3435              :           " unittest.d/50-advgetopt.ini, user.config,"
    3436              :           " unittest.d/50-user.config"
    3437              :         , 0
    3438              :         , advgetopt::get_screen_width())
    3439              : + advgetopt::format_usage_string(
    3440              :           "--verbose"
    3441              :         , "inform you of what we're currently working on:"
    3442              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3443              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3444              :           " /usr/share/unittest/options/advgetopt.conf,"
    3445              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3446              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf,"
    3447              :           " system.conf, unittest.d/50-system.conf,"
    3448              :           " advgetopt.conf, unittest.d/50-advgetopt.conf,"
    3449              :           " advgetopt.ini, unittest.d/50-advgetopt.ini,"
    3450              :           " user.config, unittest.d/50-user.config."
    3451              :         , 30
    3452              :         , advgetopt::get_screen_width()) + "\n"
    3453              : + advgetopt::breakup_line(
    3454              :           "Percent Configuration Files:"
    3455              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3456              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3457              :           " /usr/share/unittest/options/advgetopt.conf,"
    3458              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3459              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf,"
    3460              :           " system.conf, unittest.d/50-system.conf,"
    3461              :           " advgetopt.conf, unittest.d/50-advgetopt.conf, advgetopt.ini,"
    3462              :           " unittest.d/50-advgetopt.ini, user.config, unittest.d/50-user.config"
    3463              :         , 0
    3464              :         , advgetopt::get_screen_width())
    3465              :                 );
    3466            1 :     }
    3467            7 :     CATCH_END_SECTION()
    3468              : 
    3469            7 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with g (nullptr)")
    3470              :     {
    3471            1 :         const advgetopt::option options_list[] =
    3472              :         {
    3473              :             advgetopt::define_option(
    3474              :                   advgetopt::Name("verbose")
    3475              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3476              :                 , advgetopt::Help("inform you of what we're currently working on: %g.")
    3477              :             ),
    3478              :             advgetopt::end_options()
    3479              :         };
    3480            1 :         char const * cargv[] =
    3481              :         {
    3482              :             "tests/unittests/usage",
    3483              :             "--verbose",
    3484              :             nullptr
    3485              :         };
    3486            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3487            1 :         char ** argv = const_cast<char **>(cargv);
    3488              : 
    3489            1 :         advgetopt::options_environment options;
    3490            1 :         options.f_project_name = "unittest";
    3491            1 :         options.f_options = options_list;
    3492            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3493            1 :         options.f_configuration_files = nullptr;
    3494            1 :         options.f_configuration_filename = "advgetopt.conf";
    3495            1 :         options.f_configuration_directories = nullptr;
    3496            1 :         options.f_help_header = "Usage: test usage: %g";
    3497            1 :         options.f_help_footer = "Percent Configuration Files: %g";
    3498            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3499            1 :         options.f_version = "2.0.1-%g";
    3500            1 :         options.f_license = "MIT-%g";
    3501            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %g";
    3502            1 :         options.f_build_date = "Jun  4 2019 %g";
    3503            1 :         options.f_build_time = "23:02:36 %g";
    3504              : 
    3505            1 :         advgetopt::getopt opt(options, argc, argv);
    3506              : 
    3507            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3508            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3509              : "Usage: test usage: \n"
    3510              : "   --verbose                  inform you of what we're currently working on: .\n"
    3511              : "\n"
    3512              : "Percent Configuration Files: \n"
    3513              :                 );
    3514            1 :     }
    3515            7 :     CATCH_END_SECTION()
    3516              : 
    3517            7 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with g (nullptr)")
    3518              :     {
    3519            1 :         const advgetopt::option options_list[] =
    3520              :         {
    3521              :             advgetopt::define_option(
    3522              :                   advgetopt::Name("verbose")
    3523              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3524              :                 , advgetopt::Help("inform you of what we're currently working on: %*g.")
    3525              :             ),
    3526              :             advgetopt::end_options()
    3527              :         };
    3528            1 :         char const * cargv[] =
    3529              :         {
    3530              :             "tests/unittests/usage",
    3531              :             "--verbose",
    3532              :             nullptr
    3533              :         };
    3534            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3535            1 :         char ** argv = const_cast<char **>(cargv);
    3536              : 
    3537            1 :         advgetopt::options_environment options;
    3538            1 :         options.f_project_name = "unittest";
    3539            1 :         options.f_options = options_list;
    3540            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3541            1 :         options.f_configuration_files = nullptr;
    3542            1 :         options.f_configuration_filename = "advgetopt.conf";
    3543            1 :         options.f_configuration_directories = nullptr;
    3544            1 :         options.f_help_header = "Usage: test usage: %*g";
    3545            1 :         options.f_help_footer = "Percent Configuration Files: %*g";
    3546            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3547            1 :         options.f_version = "2.0.1-%*g";
    3548            1 :         options.f_license = "MIT-%*g";
    3549            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*g";
    3550            1 :         options.f_build_date = "Jun  4 2019 %*g";
    3551            1 :         options.f_build_time = "23:02:36 %*g";
    3552              : 
    3553            1 :         advgetopt::getopt opt(options, argc, argv);
    3554              : 
    3555            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3556            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3557              : advgetopt::breakup_line(
    3558              :           "Usage: test usage:"
    3559              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3560              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3561              :           " /usr/share/unittest/options/advgetopt.conf,"
    3562              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3563              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf"
    3564              :         , 0
    3565              :         , advgetopt::get_screen_width())
    3566              : + advgetopt::format_usage_string(
    3567              :           "--verbose"
    3568              :         , "inform you of what we're currently working on:"
    3569              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3570              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3571              :           " /usr/share/unittest/options/advgetopt.conf,"
    3572              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3573              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf."
    3574              :         , 30
    3575              :         , advgetopt::get_screen_width()) + "\n"
    3576              : + advgetopt::breakup_line(
    3577              :           "Percent Configuration Files:"
    3578              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3579              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3580              :           " /usr/share/unittest/options/advgetopt.conf,"
    3581              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3582              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf\n"
    3583              :         , 0
    3584              :         , advgetopt::get_screen_width())
    3585              :                 );
    3586            1 :     }
    3587            7 :     CATCH_END_SECTION()
    3588              : 
    3589            7 :     CATCH_START_SECTION("help_string_copyright: percent configuration files with g (empty array)")
    3590              :     {
    3591            1 :         const advgetopt::option options_list[] =
    3592              :         {
    3593              :             advgetopt::define_option(
    3594              :                   advgetopt::Name("verbose")
    3595              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3596              :                 , advgetopt::Help("inform you of what we're currently working on: %g.")
    3597              :             ),
    3598              :             advgetopt::end_options()
    3599              :         };
    3600            1 :         char const * cargv[] =
    3601              :         {
    3602              :             "tests/unittests/usage",
    3603              :             "--verbose",
    3604              :             nullptr
    3605              :         };
    3606            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3607            1 :         char ** argv = const_cast<char **>(cargv);
    3608              : 
    3609            1 :         const char * const configuration_files[] =
    3610              :         {
    3611              :             nullptr
    3612              :         };
    3613              : 
    3614            1 :         advgetopt::options_environment options;
    3615            1 :         options.f_project_name = "unittest";
    3616            1 :         options.f_options = options_list;
    3617            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3618            1 :         options.f_configuration_files = configuration_files;
    3619            1 :         options.f_configuration_filename = "advgetopt.conf";
    3620            1 :         options.f_configuration_directories = nullptr;
    3621            1 :         options.f_help_header = "Usage: test usage: %g";
    3622            1 :         options.f_help_footer = "Percent Configuration Files: %g";
    3623            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3624            1 :         options.f_version = "2.0.1-%g";
    3625            1 :         options.f_license = "MIT-%g";
    3626            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %g";
    3627            1 :         options.f_build_date = "Jun  4 2019 %g";
    3628            1 :         options.f_build_time = "23:02:36 %g";
    3629              : 
    3630            1 :         advgetopt::getopt opt(options, argc, argv);
    3631              : 
    3632            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3633            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3634              : "Usage: test usage: \n"
    3635              : "   --verbose                  inform you of what we're currently working on: .\n"
    3636              : "\n"
    3637              : "Percent Configuration Files: \n"
    3638              :                 );
    3639            1 :     }
    3640            7 :     CATCH_END_SECTION()
    3641              : 
    3642            7 :     CATCH_START_SECTION("help_string_copyright: percent asterisk configuration files with g (empty array)")
    3643              :     {
    3644            1 :         const advgetopt::option options_list[] =
    3645              :         {
    3646              :             advgetopt::define_option(
    3647              :                   advgetopt::Name("verbose")
    3648              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3649              :                 , advgetopt::Help("inform you of what we're currently working on: %*g.")
    3650              :             ),
    3651              :             advgetopt::end_options()
    3652              :         };
    3653            1 :         char const * cargv[] =
    3654              :         {
    3655              :             "tests/unittests/usage",
    3656              :             "--verbose",
    3657              :             nullptr
    3658              :         };
    3659            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3660            1 :         char ** argv = const_cast<char **>(cargv);
    3661              : 
    3662            1 :         const char * const configuration_files[] =
    3663              :         {
    3664              :             nullptr
    3665              :         };
    3666              : 
    3667            1 :         advgetopt::options_environment options;
    3668            1 :         options.f_project_name = "unittest";
    3669            1 :         options.f_options = options_list;
    3670            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3671            1 :         options.f_configuration_files = configuration_files;
    3672            1 :         options.f_configuration_filename = "advgetopt.conf";
    3673            1 :         options.f_configuration_directories = nullptr;
    3674            1 :         options.f_help_header = "Usage: test usage: %*g";
    3675            1 :         options.f_help_footer = "Percent Configuration Files: %*g";
    3676            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3677            1 :         options.f_version = "2.0.1-%*g";
    3678            1 :         options.f_license = "MIT-%*g";
    3679            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*g";
    3680            1 :         options.f_build_date = "Jun  4 2019 %*g";
    3681            1 :         options.f_build_time = "23:02:36 %*g";
    3682              : 
    3683            1 :         advgetopt::getopt opt(options, argc, argv);
    3684              : 
    3685            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3686            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3687              : advgetopt::breakup_line(
    3688              :           "Usage: test usage:"
    3689              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3690              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3691              :           " /usr/share/unittest/options/advgetopt.conf,"
    3692              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3693              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf"
    3694              :         , 0
    3695              :         , advgetopt::get_screen_width())
    3696              : + advgetopt::format_usage_string(
    3697              :           "--verbose"
    3698              :         , "inform you of what we're currently working on:"
    3699              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3700              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3701              :           " /usr/share/unittest/options/advgetopt.conf,"
    3702              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3703              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf."
    3704              :         , 30
    3705              :         , advgetopt::get_screen_width()) + "\n"
    3706              : + advgetopt::breakup_line(
    3707              :           "Percent Configuration Files:"
    3708              :           " /usr/share/advgetopt/options/unittest/advgetopt.conf,"
    3709              :           " /usr/share/advgetopt/options/unittest/unittest.d/50-advgetopt.conf,"
    3710              :           " /usr/share/unittest/options/advgetopt.conf,"
    3711              :           " /usr/share/unittest/options/unittest.d/50-advgetopt.conf,"
    3712              :           " /etc/unittest/advgetopt.conf, /etc/unittest/unittest.d/50-advgetopt.conf"
    3713              :         , 0
    3714              :         , advgetopt::get_screen_width())
    3715              :                 );
    3716            1 :     }
    3717            7 :     CATCH_END_SECTION()
    3718            7 : }
    3719              : 
    3720              : 
    3721              : 
    3722              : 
    3723            3 : CATCH_TEST_CASE("help_string_option_file_directory", "[getopt][usage][config]")
    3724              : {
    3725            3 :     CATCH_START_SECTION("help_string_option_file_directory: percent configuration files with i (fully defined)")
    3726              :     {
    3727            1 :         const advgetopt::option options_list[] =
    3728              :         {
    3729              :             advgetopt::define_option(
    3730              :                   advgetopt::Name("verbose")
    3731              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3732              :                 , advgetopt::Help("inform you of what we're currently working on: %i.")
    3733              :             ),
    3734              :             advgetopt::end_options()
    3735              :         };
    3736            1 :         char const * cargv[] =
    3737              :         {
    3738              :             "tests/unittests/usage",
    3739              :             "--verbose",
    3740              :             nullptr
    3741              :         };
    3742            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3743            1 :         char ** argv = const_cast<char **>(cargv);
    3744              : 
    3745            1 :         const char * const configuration_files[] =
    3746              :         {
    3747              :             "advgetopt.conf",
    3748              :             "advgetopt.ini",
    3749              :             nullptr
    3750              :         };
    3751              : 
    3752            1 :         advgetopt::options_environment options;
    3753            1 :         options.f_project_name = "unittest";
    3754            1 :         options.f_options = options_list;
    3755            1 :         options.f_options_files_directory = "/opt/advgetopt/config";
    3756            1 :         options.f_configuration_files = configuration_files;
    3757            1 :         options.f_configuration_filename = "advgetopt.conf";
    3758            1 :         options.f_configuration_directories = nullptr;
    3759            1 :         options.f_help_header = "Usage: test usage: %i";
    3760            1 :         options.f_help_footer = "Percent Configuration Files: %i";
    3761            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3762            1 :         options.f_version = "2.0.1-%i";
    3763            1 :         options.f_license = "MIT-%i";
    3764            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %i";
    3765            1 :         options.f_build_date = "Jun  4 2019 %i";
    3766            1 :         options.f_build_time = "23:02:36 %i";
    3767              : 
    3768            1 :         advgetopt::getopt opt(options, argc, argv);
    3769              : 
    3770            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3771              : 
    3772            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3773              :               "Usage: test usage: /opt/advgetopt/config/unittest.ini\n"
    3774              : + advgetopt::format_usage_string(
    3775              :               "--verbose", "inform you of what we're currently working on: "
    3776              :               "/opt/advgetopt/config/unittest.ini."
    3777              :         , 30
    3778              :         , advgetopt::get_screen_width()) + "\n"
    3779              : + advgetopt::breakup_line(
    3780              :               "Percent Configuration Files: /opt/advgetopt/config/unittest.ini"
    3781              :         , 0
    3782              :         , advgetopt::get_screen_width())
    3783              :                 );
    3784            1 :     }
    3785            3 :     CATCH_END_SECTION()
    3786              : 
    3787            3 :     CATCH_START_SECTION("help_string_option_file_directory: percent configuration files with i (nullptr)")
    3788              :     {
    3789            1 :         const advgetopt::option options_list[] =
    3790              :         {
    3791              :             advgetopt::define_option(
    3792              :                   advgetopt::Name("verbose")
    3793              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3794              :                 , advgetopt::Help("inform you of what we're currently working on: %i.")
    3795              :             ),
    3796              :             advgetopt::end_options()
    3797              :         };
    3798            1 :         char const * cargv[] =
    3799              :         {
    3800              :             "tests/unittests/usage",
    3801              :             "--verbose",
    3802              :             nullptr
    3803              :         };
    3804            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3805            1 :         char ** argv = const_cast<char **>(cargv);
    3806              : 
    3807            1 :         const char * const configuration_files[] =
    3808              :         {
    3809              :             "/ignored/in/this/test",
    3810              :             nullptr
    3811              :         };
    3812              : 
    3813            1 :         advgetopt::options_environment options;
    3814            1 :         options.f_project_name = "unittest";
    3815            1 :         options.f_options = options_list;
    3816            1 :         options.f_options_files_directory = nullptr;
    3817            1 :         options.f_configuration_files = configuration_files;
    3818            1 :         options.f_configuration_filename = "advgetopt.conf";
    3819            1 :         options.f_configuration_directories = nullptr;
    3820            1 :         options.f_help_header = "Usage: test usage: %i";
    3821            1 :         options.f_help_footer = "Percent Configuration Files: %i";
    3822            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3823            1 :         options.f_version = "2.0.1-%i";
    3824            1 :         options.f_license = "MIT-%i";
    3825            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %i";
    3826            1 :         options.f_build_date = "Jun  4 2019 %i";
    3827            1 :         options.f_build_time = "23:02:36 %i";
    3828              : 
    3829            1 :         advgetopt::getopt opt(options, argc, argv);
    3830              : 
    3831            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3832            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3833              : advgetopt::breakup_line("Usage: test usage: /usr/share/advgetopt/options/unittest.ini", 0, advgetopt::get_screen_width())
    3834              : + advgetopt::format_usage_string(
    3835              :               "--verbose"
    3836              :             , "inform you of what we're currently working on: /usr/share/advgetopt/options/unittest.ini."
    3837              :             , 30
    3838              :             , advgetopt::get_screen_width()) + "\n"
    3839              : + advgetopt::breakup_line("Percent Configuration Files: /usr/share/advgetopt/options/unittest.ini", 0, advgetopt::get_screen_width())
    3840              :                 );
    3841            1 :     }
    3842            3 :     CATCH_END_SECTION()
    3843              : 
    3844            3 :     CATCH_START_SECTION("help_string_option_file_directory: percent configuration files with i (empty string)")
    3845              :     {
    3846            1 :         const advgetopt::option options_list[] =
    3847              :         {
    3848              :             advgetopt::define_option(
    3849              :                   advgetopt::Name("verbose")
    3850              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3851              :                 , advgetopt::Help("inform you of what we're currently working on: %i.")
    3852              :             ),
    3853              :             advgetopt::end_options()
    3854              :         };
    3855            1 :         char const * cargv[] =
    3856              :         {
    3857              :             "tests/unittests/usage",
    3858              :             "--verbose",
    3859              :             nullptr
    3860              :         };
    3861            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3862            1 :         char ** argv = const_cast<char **>(cargv);
    3863              : 
    3864            1 :         const char * const configuration_files[] =
    3865              :         {
    3866              :             "/ignored/in/this/test",
    3867              :             nullptr
    3868              :         };
    3869              : 
    3870            1 :         advgetopt::options_environment options;
    3871            1 :         options.f_project_name = "unittest";
    3872            1 :         options.f_options = options_list;
    3873            1 :         options.f_options_files_directory = "";
    3874            1 :         options.f_configuration_files = configuration_files;
    3875            1 :         options.f_configuration_filename = "advgetopt.conf";
    3876            1 :         options.f_configuration_directories = nullptr;
    3877            1 :         options.f_help_header = "Usage: test usage: %i";
    3878            1 :         options.f_help_footer = "Percent Configuration Files: %i";
    3879            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3880            1 :         options.f_version = "2.0.1-%i";
    3881            1 :         options.f_license = "MIT-%i";
    3882            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %i";
    3883            1 :         options.f_build_date = "Jun  4 2019 %i";
    3884            1 :         options.f_build_time = "23:02:36 %i";
    3885              : 
    3886            1 :         advgetopt::getopt opt(options, argc, argv);
    3887              : 
    3888            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3889            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3890              : advgetopt::breakup_line("Usage: test usage: /usr/share/advgetopt/options/unittest.ini", 0, advgetopt::get_screen_width())
    3891              : + advgetopt::format_usage_string(
    3892              :                   "--verbose"
    3893              :                 , "inform you of what we're currently working on: /usr/share/advgetopt/options/unittest.ini."
    3894              :                 , 30
    3895              :                 , advgetopt::get_screen_width()) + "\n"
    3896              : + advgetopt::breakup_line("Percent Configuration Files: /usr/share/advgetopt/options/unittest.ini", 0, advgetopt::get_screen_width())
    3897              :                 );
    3898            1 :     }
    3899            3 :     CATCH_END_SECTION()
    3900            3 : }
    3901              : 
    3902              : 
    3903              : 
    3904              : 
    3905            3 : CATCH_TEST_CASE("help_string_license", "[getopt][usage]")
    3906              : {
    3907            3 :     CATCH_START_SECTION("help_string_license: percent license (defined)")
    3908              :     {
    3909            1 :         const advgetopt::option options_list[] =
    3910              :         {
    3911              :             advgetopt::define_option(
    3912              :                   advgetopt::Name("verbose")
    3913              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3914              :                 , advgetopt::Help("inform you of what we're currently working on: %l.")
    3915              :             ),
    3916              :             advgetopt::end_options()
    3917              :         };
    3918            1 :         char const * cargv[] =
    3919              :         {
    3920              :             "tests/unittests/usage",
    3921              :             "--verbose",
    3922              :             nullptr
    3923              :         };
    3924            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3925            1 :         char ** argv = const_cast<char **>(cargv);
    3926              : 
    3927            1 :         advgetopt::options_environment options;
    3928            1 :         options.f_project_name = "unittest";
    3929            1 :         options.f_options = options_list;
    3930            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3931            1 :         options.f_configuration_files = nullptr;
    3932            1 :         options.f_configuration_filename = "advgetopt.conf";
    3933            1 :         options.f_configuration_directories = nullptr;
    3934            1 :         options.f_help_header = "Usage: test usage: %l";
    3935            1 :         options.f_help_footer = "Percent License: %l";
    3936            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3937            1 :         options.f_version = "2.0.1-%l";
    3938            1 :         options.f_license = "MIT-%l";
    3939            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %l";
    3940            1 :         options.f_build_date = "Jun  4 2019 %l";
    3941            1 :         options.f_build_time = "23:02:36 %l";
    3942              : 
    3943            1 :         advgetopt::getopt opt(options, argc, argv);
    3944              : 
    3945            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3946              : 
    3947            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3948              : advgetopt::breakup_line("Usage: test usage: MIT-%l", 0, advgetopt::get_screen_width())
    3949              : + advgetopt::format_usage_string(
    3950              :               "--verbose"
    3951              :             , "inform you of what we're currently working on: MIT-%l."
    3952              :             , 30
    3953              :             , advgetopt::get_screen_width()) + "\n"
    3954              : + advgetopt::breakup_line("Percent License: MIT-%l", 0, advgetopt::get_screen_width())
    3955              :                 );
    3956            1 :     }
    3957            3 :     CATCH_END_SECTION()
    3958              : 
    3959            3 :     CATCH_START_SECTION("help_string_license: percent license (nullptr)")
    3960              :     {
    3961            1 :         const advgetopt::option options_list[] =
    3962              :         {
    3963              :             advgetopt::define_option(
    3964              :                   advgetopt::Name("verbose")
    3965              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    3966              :                 , advgetopt::Help("inform you of what we're currently working on: %l.")
    3967              :             ),
    3968              :             advgetopt::end_options()
    3969              :         };
    3970            1 :         char const * cargv[] =
    3971              :         {
    3972              :             "tests/unittests/usage",
    3973              :             "--verbose",
    3974              :             nullptr
    3975              :         };
    3976            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    3977            1 :         char ** argv = const_cast<char **>(cargv);
    3978              : 
    3979            1 :         advgetopt::options_environment options;
    3980            1 :         options.f_project_name = "unittest";
    3981            1 :         options.f_options = options_list;
    3982            1 :         options.f_options_files_directory = "/etc/advgetopt";
    3983            1 :         options.f_configuration_files = nullptr;
    3984            1 :         options.f_configuration_filename = "advgetopt.conf";
    3985            1 :         options.f_configuration_directories = nullptr;
    3986            1 :         options.f_help_header = "Usage: test usage: %l";
    3987            1 :         options.f_help_footer = "Percent License: %l";
    3988            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    3989            1 :         options.f_version = "2.0.1-%l";
    3990            1 :         options.f_license = nullptr;
    3991            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %l";
    3992            1 :         options.f_build_date = "Jun  4 2019 %l";
    3993            1 :         options.f_build_time = "23:02:36 %l";
    3994              : 
    3995            1 :         advgetopt::getopt opt(options, argc, argv);
    3996              : 
    3997            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    3998            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    3999              : "Usage: test usage: %l\n"
    4000              : "   --verbose                  inform you of what we're currently working on: %l.\n"
    4001              : "\n"
    4002              : "Percent License: %l\n"
    4003              :                 );
    4004            1 :     }
    4005            3 :     CATCH_END_SECTION()
    4006              : 
    4007            3 :     CATCH_START_SECTION("help_string_license: percent license (\"\")")
    4008              :     {
    4009            1 :         const advgetopt::option options_list[] =
    4010              :         {
    4011              :             advgetopt::define_option(
    4012              :                   advgetopt::Name("verbose")
    4013              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4014              :                 , advgetopt::Help("inform you of what we're currently working on: %l.")
    4015              :             ),
    4016              :             advgetopt::end_options()
    4017              :         };
    4018            1 :         char const * cargv[] =
    4019              :         {
    4020              :             "tests/unittests/usage",
    4021              :             "--verbose",
    4022              :             nullptr
    4023              :         };
    4024            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4025            1 :         char ** argv = const_cast<char **>(cargv);
    4026              : 
    4027            1 :         advgetopt::options_environment options;
    4028            1 :         options.f_project_name = "unittest";
    4029            1 :         options.f_options = options_list;
    4030            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4031            1 :         options.f_configuration_files = nullptr;
    4032            1 :         options.f_configuration_filename = "advgetopt.conf";
    4033            1 :         options.f_configuration_directories = nullptr;
    4034            1 :         options.f_help_header = "Usage: test usage: %l";
    4035            1 :         options.f_help_footer = "Percent License: %l";
    4036            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4037            1 :         options.f_version = "2.0.1-%l";
    4038            1 :         options.f_license = "";
    4039            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %l";
    4040            1 :         options.f_build_date = "Jun  4 2019 %l";
    4041            1 :         options.f_build_time = "23:02:36 %l";
    4042              : 
    4043            1 :         advgetopt::getopt opt(options, argc, argv);
    4044              : 
    4045            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4046            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4047              : "Usage: test usage: \n"
    4048              : "   --verbose                  inform you of what we're currently working on: .\n"
    4049              : "\n"
    4050              : "Percent License: \n"
    4051              :                 );
    4052            1 :     }
    4053            3 :     CATCH_END_SECTION()
    4054            3 : }
    4055              : 
    4056              : 
    4057              : 
    4058              : 
    4059            3 : CATCH_TEST_CASE("help_string_configuration_output_file", "[getopt][usage][config]")
    4060              : {
    4061            3 :     CATCH_START_SECTION("help_string_license: percent configuration output file (fully defined)")
    4062              :     {
    4063            1 :         const advgetopt::option options_list[] =
    4064              :         {
    4065              :             advgetopt::define_option(
    4066              :                   advgetopt::Name("verbose")
    4067              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4068              :                 , advgetopt::Help("inform you of what we're currently working on: %o.")
    4069              :             ),
    4070              :             advgetopt::end_options()
    4071              :         };
    4072            1 :         char const * cargv[] =
    4073              :         {
    4074              :             "tests/unittests/usage",
    4075              :             "--verbose",
    4076              :             nullptr
    4077              :         };
    4078            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4079            1 :         char ** argv = const_cast<char **>(cargv);
    4080              : 
    4081            1 :         const char * const configuration_files[] =
    4082              :         {
    4083              :             "system.conf",
    4084              :             "advgetopt.conf",
    4085              :             "advgetopt.ini",
    4086              :             "user.config",
    4087              :             nullptr
    4088              :         };
    4089              : 
    4090            1 :         advgetopt::options_environment options;
    4091            1 :         options.f_project_name = "unittest";
    4092            1 :         options.f_options = options_list;
    4093            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4094            1 :         options.f_configuration_files = configuration_files;
    4095            1 :         options.f_configuration_filename = "advgetopt.conf";
    4096            1 :         options.f_configuration_directories = nullptr;
    4097            1 :         options.f_help_header = "Usage: test usage: %o";
    4098            1 :         options.f_help_footer = "Percent Configuration Files: %o";
    4099            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4100            1 :         options.f_version = "2.0.1-%o";
    4101            1 :         options.f_license = "MIT-%o";
    4102            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %o";
    4103            1 :         options.f_build_date = "Jun  4 2019 %o";
    4104            1 :         options.f_build_time = "23:02:36 %o";
    4105              : 
    4106            1 :         advgetopt::getopt opt(options, argc, argv);
    4107              : 
    4108            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4109              : 
    4110            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4111              : advgetopt::breakup_line("Usage: test usage: unittest.d/50-user.config", 0, advgetopt::get_screen_width())
    4112              : + advgetopt::format_usage_string(
    4113              :           "--verbose"
    4114              :         , "inform you of what we're currently working on: unittest.d/50-user.config."
    4115              :         , 30
    4116              :         , advgetopt::get_screen_width()) + "\n"
    4117              : + advgetopt::breakup_line("Percent Configuration Files: unittest.d/50-user.config", 0, advgetopt::get_screen_width())
    4118              :                 );
    4119            1 :     }
    4120            3 :     CATCH_END_SECTION()
    4121              : 
    4122            3 :     CATCH_START_SECTION("help_string_license: percent configuration output file (nullptr)")
    4123              :     {
    4124            1 :         const advgetopt::option options_list[] =
    4125              :         {
    4126              :             advgetopt::define_option(
    4127              :                   advgetopt::Name("verbose")
    4128              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4129              :                 , advgetopt::Help("inform you of what we're currently working on: %o.")
    4130              :             ),
    4131              :             advgetopt::end_options()
    4132              :         };
    4133            1 :         char const * cargv[] =
    4134              :         {
    4135              :             "tests/unittests/usage",
    4136              :             "--verbose",
    4137              :             nullptr
    4138              :         };
    4139            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4140            1 :         char ** argv = const_cast<char **>(cargv);
    4141              : 
    4142            1 :         advgetopt::options_environment options;
    4143            1 :         options.f_project_name = "unittest";
    4144            1 :         options.f_options = options_list;
    4145            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4146            1 :         options.f_configuration_files = nullptr;
    4147            1 :         options.f_configuration_filename = "advgetopt.conf";
    4148            1 :         options.f_configuration_directories = nullptr;
    4149            1 :         options.f_help_header = "Usage: test usage: %o";
    4150            1 :         options.f_help_footer = "Percent Configuration Files: %o";
    4151            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4152            1 :         options.f_version = "2.0.1-%o";
    4153            1 :         options.f_license = "MIT-%o";
    4154            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %o";
    4155            1 :         options.f_build_date = "Jun  4 2019 %o";
    4156            1 :         options.f_build_time = "23:02:36 %o";
    4157              : 
    4158            1 :         advgetopt::getopt opt(options, argc, argv);
    4159              : 
    4160            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4161            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4162              : advgetopt::breakup_line(
    4163              :           "Usage: test usage: /etc/unittest/unittest.d/50-advgetopt.conf\n"
    4164              :         , 0
    4165              :         , advgetopt::get_screen_width())
    4166              : + advgetopt::format_usage_string(
    4167              :           "--verbose"
    4168              :         , "inform you of what we're currently working on:"
    4169              :           " /etc/unittest/unittest.d/50-advgetopt.conf."
    4170              :         , 30
    4171              :         , advgetopt::get_screen_width()) + "\n"
    4172              : + advgetopt::breakup_line(
    4173              :           "Percent Configuration Files: /etc/unittest/unittest.d/50-advgetopt.conf\n"
    4174              :         , 0
    4175              :         , advgetopt::get_screen_width())
    4176              :                 );
    4177            1 :     }
    4178            3 :     CATCH_END_SECTION()
    4179              : 
    4180            3 :     CATCH_START_SECTION("help_string_license: percent configuration output file (empty array)")
    4181              :     {
    4182            1 :         const advgetopt::option options_list[] =
    4183              :         {
    4184              :             advgetopt::define_option(
    4185              :                   advgetopt::Name("verbose")
    4186              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4187              :                 , advgetopt::Help("inform you of what we're currently working on: %o.")
    4188              :             ),
    4189              :             advgetopt::end_options()
    4190              :         };
    4191            1 :         char const * cargv[] =
    4192              :         {
    4193              :             "tests/unittests/usage",
    4194              :             "--verbose",
    4195              :             nullptr
    4196              :         };
    4197            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4198            1 :         char ** argv = const_cast<char **>(cargv);
    4199              : 
    4200            1 :         const char * const configuration_files[] =
    4201              :         {
    4202              :             nullptr
    4203              :         };
    4204              : 
    4205            1 :         advgetopt::options_environment options;
    4206            1 :         options.f_project_name = "unittest";
    4207            1 :         options.f_options = options_list;
    4208            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4209            1 :         options.f_configuration_files = configuration_files;
    4210            1 :         options.f_configuration_filename = "advgetopt.conf";
    4211            1 :         options.f_configuration_directories = nullptr;
    4212            1 :         options.f_help_header = "Usage: test usage: %o";
    4213            1 :         options.f_help_footer = "Percent Configuration Files: %o";
    4214            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4215            1 :         options.f_version = "2.0.1-%o";
    4216            1 :         options.f_license = "MIT-%o";
    4217            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %o";
    4218            1 :         options.f_build_date = "Jun  4 2019 %o";
    4219            1 :         options.f_build_time = "23:02:36 %o";
    4220              : 
    4221            1 :         advgetopt::getopt opt(options, argc, argv);
    4222              : 
    4223            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4224            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4225              : advgetopt::breakup_line(
    4226              :           "Usage: test usage: /etc/unittest/unittest.d/50-advgetopt.conf\n"
    4227              :         , 0
    4228              :         , advgetopt::get_screen_width())
    4229              : + advgetopt::format_usage_string(
    4230              :           "--verbose"
    4231              :         , "inform you of what we're currently working on:"
    4232              :           " /etc/unittest/unittest.d/50-advgetopt.conf.\n"
    4233              :         , 30
    4234              :         , advgetopt::get_screen_width()) + "\n"
    4235              : + advgetopt::breakup_line(
    4236              :           "Percent Configuration Files:"
    4237              :           " /etc/unittest/unittest.d/50-advgetopt.conf\n"
    4238              :         , 0
    4239              :         , advgetopt::get_screen_width())
    4240              :                 );
    4241            1 :     }
    4242            3 :     CATCH_END_SECTION()
    4243            3 : }
    4244              : 
    4245              : 
    4246              : 
    4247              : 
    4248              : 
    4249              : 
    4250            3 : CATCH_TEST_CASE("help_string_program_name", "[getopt][usage]")
    4251              : {
    4252            3 :     CATCH_START_SECTION("help_string_program_name: percent program name")
    4253              :     {
    4254            1 :         const advgetopt::option options_list[] =
    4255              :         {
    4256              :             advgetopt::define_option(
    4257              :                   advgetopt::Name("verbose")
    4258              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
    4259              :                 , advgetopt::Help("inform you of what we're currently working on: %p.")
    4260              :             ),
    4261              :             advgetopt::end_options()
    4262              :         };
    4263            1 :         char const * cargv[] =
    4264              :         {
    4265              :             "tests/unittests/usage",
    4266              :             "--verbose",
    4267              :             nullptr
    4268              :         };
    4269            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4270            1 :         char ** argv = const_cast<char **>(cargv);
    4271              : 
    4272            1 :         advgetopt::options_environment options;
    4273            1 :         options.f_project_name = "unittest";
    4274            1 :         options.f_options = options_list;
    4275            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4276            1 :         options.f_configuration_files = nullptr;
    4277            1 :         options.f_configuration_filename = "advgetopt.conf";
    4278            1 :         options.f_configuration_directories = nullptr;
    4279            1 :         options.f_help_header = "Usage: test usage: %p";
    4280            1 :         options.f_help_footer = "Percent Program Name: %p";
    4281            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4282            1 :         options.f_version = "2.0.1-%p";
    4283            1 :         options.f_license = "MIT-%p";
    4284            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %p";
    4285            1 :         options.f_build_date = "Jun  4 2019 %p";
    4286            1 :         options.f_build_time = "23:02:36 %p";
    4287              : 
    4288            1 :         advgetopt::getopt opt(options, argc, argv);
    4289              : 
    4290            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4291              : 
    4292            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4293              : advgetopt::breakup_line("Usage: test usage: usage", 0, advgetopt::get_screen_width())
    4294              : + advgetopt::format_usage_string(
    4295              :           "--verbose"
    4296              :         , "inform you of what we're currently working on: usage."
    4297              :         , 30
    4298              :         , advgetopt::get_screen_width()) + "\n"
    4299              : + advgetopt::breakup_line("Percent Program Name: usage", 0, advgetopt::get_screen_width())
    4300              :                 );
    4301            1 :     }
    4302            3 :     CATCH_END_SECTION()
    4303              : 
    4304            3 :     CATCH_START_SECTION("help_string_program_name: percent asterisk program name")
    4305              :     {
    4306            1 :         const advgetopt::option options_list[] =
    4307              :         {
    4308              :             advgetopt::define_option(
    4309              :                   advgetopt::Name("verbose")
    4310              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
    4311              :                 , advgetopt::Help("inform you of what we're currently working on: %*p.")
    4312              :             ),
    4313              :             advgetopt::end_options()
    4314              :         };
    4315            1 :         char const * cargv[] =
    4316              :         {
    4317              :             "tests/unittests/usage",
    4318              :             "--verbose",
    4319              :             nullptr
    4320              :         };
    4321            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4322            1 :         char ** argv = const_cast<char **>(cargv);
    4323              : 
    4324            1 :         advgetopt::options_environment options;
    4325            1 :         options.f_project_name = "unittest";
    4326            1 :         options.f_options = options_list;
    4327            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4328            1 :         options.f_configuration_files = nullptr;
    4329            1 :         options.f_configuration_filename = "advgetopt.conf";
    4330            1 :         options.f_configuration_directories = nullptr;
    4331            1 :         options.f_help_header = "Usage: test usage: %*p";
    4332            1 :         options.f_help_footer = "Percent Program Name: %*p";
    4333            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4334            1 :         options.f_version = "2.0.1-%*p";
    4335            1 :         options.f_license = "MIT-%*p";
    4336            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %*p";
    4337            1 :         options.f_build_date = "Jun  4 2019 %*p";
    4338            1 :         options.f_build_time = "23:02:36 %*p";
    4339              : 
    4340            1 :         advgetopt::getopt opt(options, argc, argv);
    4341              : 
    4342            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4343              : 
    4344            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4345              : advgetopt::breakup_line("Usage: test usage: tests/unittests/usage", 0, advgetopt::get_screen_width())
    4346              : + advgetopt::format_usage_string(
    4347              :               "--verbose"
    4348              :             , "inform you of what we're currently working on: tests/unittests/usage."
    4349              :             , 30
    4350              :             , advgetopt::get_screen_width()) + "\n"
    4351              : + advgetopt::breakup_line("Percent Program Name: tests/unittests/usage", 0, advgetopt::get_screen_width())
    4352              :                 );
    4353            1 :     }
    4354            3 :     CATCH_END_SECTION()
    4355              : 
    4356            3 :     CATCH_START_SECTION("help_string_program_name: percent program name (empty--before parsing the arguments)")
    4357              :     {
    4358            1 :         const advgetopt::option options_list[] =
    4359              :         {
    4360              :             advgetopt::define_option(
    4361              :                   advgetopt::Name("verbose")
    4362              :                 , advgetopt::Flags(advgetopt::command_flags<advgetopt::GETOPT_FLAG_FLAG>())
    4363              :                 , advgetopt::Help("inform you of what we're currently working on: %p.")
    4364              :             ),
    4365              :             advgetopt::end_options()
    4366              :         };
    4367              : 
    4368            1 :         advgetopt::options_environment options;
    4369            1 :         options.f_project_name = "unittest";
    4370            1 :         options.f_options = options_list;
    4371            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4372            1 :         options.f_configuration_files = nullptr;
    4373            1 :         options.f_configuration_filename = "advgetopt.conf";
    4374            1 :         options.f_configuration_directories = nullptr;
    4375            1 :         options.f_help_header = "Usage: test usage: %p";
    4376            1 :         options.f_help_footer = "Percent Program Name: %p";
    4377            1 :         options.f_environment_variable_name = nullptr;
    4378            1 :         options.f_version = "2.0.1-%p";
    4379            1 :         options.f_license = "MIT-%p";
    4380            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %p";
    4381            1 :         options.f_build_date = "Jun  4 2019 %p";
    4382            1 :         options.f_build_time = "23:02:36 %p";
    4383              : 
    4384            1 :         advgetopt::getopt opt(options);
    4385              : 
    4386            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4387            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4388              : "Usage: test usage: \n"
    4389              : "   --verbose                  inform you of what we're currently working on: .\n"
    4390              : "\n"
    4391              : "Percent Program Name: \n"
    4392              :                 );
    4393            1 :     }
    4394            3 :     CATCH_END_SECTION()
    4395            3 : }
    4396              : 
    4397              : 
    4398              : 
    4399              : 
    4400              : 
    4401            3 : CATCH_TEST_CASE("help_string_build_time", "[getopt][usage]")
    4402              : {
    4403            3 :     CATCH_START_SECTION("help_string_build_time: percent build time (defined)")
    4404              :     {
    4405            1 :         const advgetopt::option options_list[] =
    4406              :         {
    4407              :             advgetopt::define_option(
    4408              :                   advgetopt::Name("verbose")
    4409              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4410              :                 , advgetopt::Help("inform you of what we're currently working on: %t.")
    4411              :             ),
    4412              :             advgetopt::end_options()
    4413              :         };
    4414            1 :         char const * cargv[] =
    4415              :         {
    4416              :             "tests/unittests/usage",
    4417              :             "--verbose",
    4418              :             nullptr
    4419              :         };
    4420            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4421            1 :         char ** argv = const_cast<char **>(cargv);
    4422              : 
    4423            1 :         advgetopt::options_environment options;
    4424            1 :         options.f_project_name = "unittest";
    4425            1 :         options.f_options = options_list;
    4426            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4427            1 :         options.f_configuration_files = nullptr;
    4428            1 :         options.f_configuration_filename = "advgetopt.conf";
    4429            1 :         options.f_configuration_directories = nullptr;
    4430            1 :         options.f_help_header = "Usage: test usage: %t";
    4431            1 :         options.f_help_footer = "Percent Build Time: %t";
    4432            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4433            1 :         options.f_version = "2.0.1-%t";
    4434            1 :         options.f_license = "MIT-%t";
    4435            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %t";
    4436            1 :         options.f_build_date = "Jun  4 2019 %t";
    4437            1 :         options.f_build_time = "23:02:36 %t";
    4438              : 
    4439            1 :         advgetopt::getopt opt(options, argc, argv);
    4440              : 
    4441            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4442            9 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4443              : advgetopt::breakup_line("Usage: test usage: 23:02:36 %t", 0, advgetopt::get_screen_width())
    4444              : + advgetopt::format_usage_string(
    4445              :           "--verbose"
    4446              :         , "inform you of what we're currently working on: 23:02:36 %t."
    4447              :         , 30
    4448              :         , advgetopt::get_screen_width()) + "\n"
    4449              : + advgetopt::breakup_line("Percent Build Time: 23:02:36 %t", 0, advgetopt::get_screen_width())
    4450              :                 );
    4451            1 :     }
    4452            3 :     CATCH_END_SECTION()
    4453              : 
    4454            3 :     CATCH_START_SECTION("help_string_build_time: percent build time (nullptr)")
    4455              :     {
    4456            1 :         const advgetopt::option options_list[] =
    4457              :         {
    4458              :             advgetopt::define_option(
    4459              :                   advgetopt::Name("verbose")
    4460              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4461              :                 , advgetopt::Help("inform you of what we're currently working on: %t.")
    4462              :             ),
    4463              :             advgetopt::end_options()
    4464              :         };
    4465            1 :         char const * cargv[] =
    4466              :         {
    4467              :             "tests/unittests/usage",
    4468              :             "--verbose",
    4469              :             nullptr
    4470              :         };
    4471            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4472            1 :         char ** argv = const_cast<char **>(cargv);
    4473              : 
    4474            1 :         advgetopt::options_environment options;
    4475            1 :         options.f_project_name = "unittest";
    4476            1 :         options.f_options = options_list;
    4477            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4478            1 :         options.f_configuration_files = nullptr;
    4479            1 :         options.f_configuration_filename = "advgetopt.conf";
    4480            1 :         options.f_configuration_directories = nullptr;
    4481            1 :         options.f_help_header = "Usage: test usage: %t";
    4482            1 :         options.f_help_footer = "Percent Build Time: %t";
    4483            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4484            1 :         options.f_version = "2.0.1-%t";
    4485            1 :         options.f_license = "MIT-%t";
    4486            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %t";
    4487            1 :         options.f_build_date = "Jun  4 2019 %t";
    4488            1 :         options.f_build_time = nullptr;
    4489              : 
    4490            1 :         advgetopt::getopt opt(options, argc, argv);
    4491              : 
    4492            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4493            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4494              : "Usage: test usage: %t\n"
    4495              : "   --verbose                  inform you of what we're currently working on: %t.\n"
    4496              : "\n"
    4497              : "Percent Build Time: %t\n"
    4498              : // TBD -- apparently that works as is?!
    4499              : //advgetopt::breakup_line("Usage: test usage: ", 0, advgetopt::get_screen_width())
    4500              : //+ advgetopt::format_usage_string(
    4501              : //          "--verbose"
    4502              : //        , "inform you of what we're currently working on: ."
    4503              : //        , 30
    4504              : //        , advgetopt::get_screen_width()) + "\n"
    4505              : //+ advgetopt::breakup_line("Percent Build Time: ", 0, advgetopt::get_screen_width())
    4506              :                 );
    4507            1 :     }
    4508            3 :     CATCH_END_SECTION()
    4509              : 
    4510            3 :     CATCH_START_SECTION("help_string_build_time: percent build time (\"\")")
    4511              :     {
    4512            1 :         const advgetopt::option options_list[] =
    4513              :         {
    4514              :             advgetopt::define_option(
    4515              :                   advgetopt::Name("verbose")
    4516              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4517              :                 , advgetopt::Help("inform you of what we're currently working on: %t.")
    4518              :             ),
    4519              :             advgetopt::end_options()
    4520              :         };
    4521            1 :         char const * cargv[] =
    4522              :         {
    4523              :             "tests/unittests/usage",
    4524              :             "--verbose",
    4525              :             nullptr
    4526              :         };
    4527            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4528            1 :         char ** argv = const_cast<char **>(cargv);
    4529              : 
    4530            1 :         advgetopt::options_environment options;
    4531            1 :         options.f_project_name = "unittest";
    4532            1 :         options.f_options = options_list;
    4533            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4534            1 :         options.f_configuration_files = nullptr;
    4535            1 :         options.f_configuration_filename = "advgetopt.conf";
    4536            1 :         options.f_configuration_directories = nullptr;
    4537            1 :         options.f_help_header = "Usage: test usage: %t";
    4538            1 :         options.f_help_footer = "Percent Build Time: %t";
    4539            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4540            1 :         options.f_version = "2.0.1-%t";
    4541            1 :         options.f_license = "MIT-%t";
    4542            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %t";
    4543            1 :         options.f_build_date = "Jun  4 2019 %t";
    4544            1 :         options.f_build_time = "";
    4545              : 
    4546            1 :         advgetopt::getopt opt(options, argc, argv);
    4547              : 
    4548            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4549            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4550              : "Usage: test usage: \n"
    4551              : "   --verbose                  inform you of what we're currently working on: .\n"
    4552              : "\n"
    4553              : "Percent Build Time: \n"
    4554              :                 );
    4555            1 :     }
    4556            3 :     CATCH_END_SECTION()
    4557            3 : }
    4558              : 
    4559              : 
    4560              : 
    4561              : 
    4562            3 : CATCH_TEST_CASE("help_string_version", "[getopt][usage]")
    4563              : {
    4564            3 :     CATCH_START_SECTION("help_string_version: percent version (defined)")
    4565              :     {
    4566            1 :         const advgetopt::option options_list[] =
    4567              :         {
    4568              :             advgetopt::define_option(
    4569              :                   advgetopt::Name("verbose")
    4570              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4571              :                 , advgetopt::Help("inform you of what we're currently working on: %v.")
    4572              :             ),
    4573              :             advgetopt::end_options()
    4574              :         };
    4575            1 :         char const * cargv[] =
    4576              :         {
    4577              :             "tests/unittests/usage",
    4578              :             "--verbose",
    4579              :             nullptr
    4580              :         };
    4581            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4582            1 :         char ** argv = const_cast<char **>(cargv);
    4583              : 
    4584            1 :         advgetopt::options_environment options;
    4585            1 :         options.f_project_name = "unittest";
    4586            1 :         options.f_options = options_list;
    4587            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4588            1 :         options.f_configuration_files = nullptr;
    4589            1 :         options.f_configuration_filename = "advgetopt.conf";
    4590            1 :         options.f_configuration_directories = nullptr;
    4591            1 :         options.f_help_header = "Usage: test usage: %v";
    4592            1 :         options.f_help_footer = "Percent Version: %v";
    4593            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4594            1 :         options.f_version = "2.0.1-%v";
    4595            1 :         options.f_license = "MIT-%v";
    4596            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %v";
    4597            1 :         options.f_build_date = "Jun  4 2019 %v";
    4598            1 :         options.f_build_time = "23:02:36 %v";
    4599              : 
    4600            1 :         advgetopt::getopt opt(options, argc, argv);
    4601              : 
    4602            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4603            7 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4604              : advgetopt::breakup_line("Usage: test usage: 2.0.1-%v", 0, advgetopt::get_screen_width())
    4605              : + advgetopt::format_usage_string(
    4606              :           "--verbose"
    4607              :         , "inform you of what we're currently working on: 2.0.1-%v."
    4608              :         , 30
    4609              :         , advgetopt::get_screen_width()) + "\n"
    4610              :   "Percent Version: 2.0.1-%v\n"
    4611              :                 );
    4612            1 :     }
    4613            3 :     CATCH_END_SECTION()
    4614              : 
    4615            3 :     CATCH_START_SECTION("help_string_version: percent version (nullptr)")
    4616              :     {
    4617            1 :         const advgetopt::option options_list[] =
    4618              :         {
    4619              :             advgetopt::define_option(
    4620              :                   advgetopt::Name("verbose")
    4621              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4622              :                 , advgetopt::Help("inform you of what we're currently working on: %v.")
    4623              :             ),
    4624              :             advgetopt::end_options()
    4625              :         };
    4626            1 :         char const * cargv[] =
    4627              :         {
    4628              :             "tests/unittests/usage",
    4629              :             "--verbose",
    4630              :             nullptr
    4631              :         };
    4632            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4633            1 :         char ** argv = const_cast<char **>(cargv);
    4634              : 
    4635            1 :         advgetopt::options_environment options;
    4636            1 :         options.f_project_name = "unittest";
    4637            1 :         options.f_options = options_list;
    4638            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4639            1 :         options.f_configuration_files = nullptr;
    4640            1 :         options.f_configuration_filename = "advgetopt.conf";
    4641            1 :         options.f_configuration_directories = nullptr;
    4642            1 :         options.f_help_header = "Usage: test usage: %v";
    4643            1 :         options.f_help_footer = "Percent Version: %v";
    4644            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4645            1 :         options.f_version = nullptr;
    4646            1 :         options.f_license = "MIT-%v";
    4647            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %v";
    4648            1 :         options.f_build_date = "Jun  4 2019 %v";
    4649            1 :         options.f_build_time = "23:02:36 %v";
    4650              : 
    4651            1 :         advgetopt::getopt opt(options, argc, argv);
    4652              : 
    4653            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4654            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4655              : "Usage: test usage: %v\n"
    4656              : "   --verbose                  inform you of what we're currently working on: %v.\n"
    4657              : "\n"
    4658              : "Percent Version: %v\n"
    4659              :                 );
    4660            1 :     }
    4661            3 :     CATCH_END_SECTION()
    4662              : 
    4663            3 :     CATCH_START_SECTION("help_string_version: percent version (\"\")")
    4664              :     {
    4665            1 :         const advgetopt::option options_list[] =
    4666              :         {
    4667              :             advgetopt::define_option(
    4668              :                   advgetopt::Name("verbose")
    4669              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4670              :                 , advgetopt::Help("inform you of what we're currently working on: %v.")
    4671              :             ),
    4672              :             advgetopt::end_options()
    4673              :         };
    4674            1 :         char const * cargv[] =
    4675              :         {
    4676              :             "tests/unittests/usage",
    4677              :             "--verbose",
    4678              :             nullptr
    4679              :         };
    4680            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4681            1 :         char ** argv = const_cast<char **>(cargv);
    4682              : 
    4683            1 :         advgetopt::options_environment options;
    4684            1 :         options.f_project_name = "unittest";
    4685            1 :         options.f_options = options_list;
    4686            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4687            1 :         options.f_configuration_files = nullptr;
    4688            1 :         options.f_configuration_filename = "advgetopt.conf";
    4689            1 :         options.f_configuration_directories = nullptr;
    4690            1 :         options.f_help_header = "Usage: test usage: %v";
    4691            1 :         options.f_help_footer = "Percent Version: %v";
    4692            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4693            1 :         options.f_version = "";
    4694            1 :         options.f_license = "MIT-%v";
    4695            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %v";
    4696            1 :         options.f_build_date = "Jun  4 2019 %v";
    4697            1 :         options.f_build_time = "23:02:36 %v";
    4698              : 
    4699            1 :         advgetopt::getopt opt(options, argc, argv);
    4700              : 
    4701            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4702            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4703              : "Usage: test usage: \n"
    4704              : "   --verbose                  inform you of what we're currently working on: .\n"
    4705              : "\n"
    4706              : "Percent Version: \n"
    4707              :                 );
    4708            1 :     }
    4709            3 :     CATCH_END_SECTION()
    4710            3 : }
    4711              : 
    4712              : 
    4713              : 
    4714              : 
    4715              : 
    4716            4 : CATCH_TEST_CASE("help_string_writable_configuration_files", "[getopt][usage][config]")
    4717              : {
    4718            4 :     CATCH_START_SECTION("help_string_writable_configuration_files: percent writable configuration files (fully defined--one file)")
    4719              :     {
    4720            5 :         SNAP_CATCH2_NAMESPACE::init_tmp_dir("config_writable_filenames", "writable_filenames");
    4721              : 
    4722              :         {
    4723            1 :             std::ofstream config_file;
    4724            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4725            1 :             CATCH_REQUIRE(config_file.good());
    4726              :             config_file <<
    4727            1 :                 "# Auto-generated\n"
    4728              :             ;
    4729            1 :         }
    4730              : 
    4731              :         {
    4732            1 :             std::ofstream config_file;
    4733            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_project_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4734            1 :             CATCH_REQUIRE(config_file.good());
    4735              :             config_file <<
    4736            1 :                 "# Auto-generated\n"
    4737              :             ;
    4738            1 :         }
    4739              : 
    4740            1 :         const advgetopt::option options_list[] =
    4741              :         {
    4742              :             advgetopt::define_option(
    4743              :                   advgetopt::Name("verbose")
    4744              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4745              :                 , advgetopt::Help("inform you of what we're currently working on: %w.")
    4746              :             ),
    4747              :             advgetopt::end_options()
    4748              :         };
    4749            1 :         char const * cargv[] =
    4750              :         {
    4751              :             "tests/unittests/usage",
    4752              :             "--verbose",
    4753              :             nullptr
    4754              :         };
    4755            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4756            1 :         char ** argv = const_cast<char **>(cargv);
    4757              : 
    4758            1 :         const char * const configuration_files[] =
    4759              :         {
    4760              :             "system.conf",
    4761              :             "advgetopt.conf",
    4762            1 :             SNAP_CATCH2_NAMESPACE::g_config_filename.c_str(),
    4763              :             "advgetopt.ini",
    4764              :             "user.config",
    4765            1 :             SNAP_CATCH2_NAMESPACE::g_config_project_filename.c_str(),
    4766              :             nullptr
    4767            1 :         };
    4768              : 
    4769            1 :         advgetopt::options_environment options;
    4770            1 :         options.f_project_name = "config_writable_filenames";
    4771            1 :         options.f_options = options_list;
    4772            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4773            1 :         options.f_configuration_files = configuration_files;
    4774            1 :         options.f_configuration_filename = "advgetopt.conf";
    4775            1 :         options.f_configuration_directories = nullptr;
    4776            1 :         options.f_help_header = "Usage: test usage: %w";
    4777            1 :         options.f_help_footer = "Percent Configuration Files: %w";
    4778            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4779            1 :         options.f_version = "2.0.1-%w";
    4780            1 :         options.f_license = "MIT-%w";
    4781            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %w";
    4782            1 :         options.f_build_date = "Jun  4 2019 %w";
    4783            1 :         options.f_build_time = "23:02:36 %w";
    4784              : 
    4785            1 :         advgetopt::getopt opt(options, argc, argv);
    4786              : 
    4787            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4788              : 
    4789            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4790              : advgetopt::breakup_line(
    4791              :               "Usage: test usage: "
    4792              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    4793              :         , 0
    4794              :         , advgetopt::get_screen_width())
    4795              : + advgetopt::format_usage_string(
    4796              :               "--verbose", "inform you of what we're currently working on: "
    4797              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename + "."
    4798              :         , 30
    4799              :         , advgetopt::get_screen_width()) + "\n"
    4800              : + advgetopt::breakup_line(
    4801              :               "Percent Configuration Files: "
    4802              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    4803              :         , 0
    4804              :         , advgetopt::get_screen_width())
    4805              :                 );
    4806            1 :     }
    4807            4 :     CATCH_END_SECTION()
    4808              : 
    4809            4 :     CATCH_START_SECTION("help_string_writable_configuration_files: percent writable configuration files (fully defined)")
    4810              :     {
    4811            5 :         SNAP_CATCH2_NAMESPACE::init_tmp_dir("config_writable_filenames", "writable_filenames");
    4812            1 :         std::string const save_config_filename(SNAP_CATCH2_NAMESPACE::g_config_filename);
    4813            1 :         std::string const save_config_project_filename(SNAP_CATCH2_NAMESPACE::g_config_project_filename);
    4814              : 
    4815            5 :         SNAP_CATCH2_NAMESPACE::init_tmp_dir("config_writable_filenames", "writable_filenames_two");
    4816              : 
    4817              :         {
    4818            1 :             std::ofstream config_file;
    4819            1 :             config_file.open(save_config_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4820            1 :             CATCH_REQUIRE(config_file.good());
    4821              :             config_file <<
    4822            1 :                 "# Auto-generated\n"
    4823              :             ;
    4824            1 :         }
    4825              : 
    4826              :         {
    4827            1 :             std::ofstream config_file;
    4828            1 :             config_file.open(save_config_project_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4829            1 :             CATCH_REQUIRE(config_file.good());
    4830              :             config_file <<
    4831            1 :                 "# Auto-generated\n"
    4832              :             ;
    4833            1 :         }
    4834              : 
    4835              :         {
    4836            1 :             std::ofstream config_file;
    4837            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4838            1 :             CATCH_REQUIRE(config_file.good());
    4839              :             config_file <<
    4840            1 :                 "# Auto-generated\n"
    4841              :             ;
    4842            1 :         }
    4843              : 
    4844              :         {
    4845            1 :             std::ofstream config_file;
    4846            1 :             config_file.open(SNAP_CATCH2_NAMESPACE::g_config_project_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
    4847            1 :             CATCH_REQUIRE(config_file.good());
    4848              :             config_file <<
    4849            1 :                 "# Auto-generated\n"
    4850              :             ;
    4851            1 :         }
    4852              : 
    4853            1 :         const advgetopt::option options_list[] =
    4854              :         {
    4855              :             advgetopt::define_option(
    4856              :                   advgetopt::Name("verbose")
    4857              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4858              :                 , advgetopt::Help("inform you of what we're currently working on: %w.")
    4859              :             ),
    4860              :             advgetopt::end_options()
    4861              :         };
    4862            1 :         char const * cargv[] =
    4863              :         {
    4864              :             "tests/unittests/usage",
    4865              :             "--verbose",
    4866              :             nullptr
    4867              :         };
    4868            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4869            1 :         char ** argv = const_cast<char **>(cargv);
    4870              : 
    4871            1 :         const char * const configuration_files[] =
    4872              :         {
    4873              :             "system.conf",
    4874            1 :             save_config_project_filename.c_str(),
    4875              :             "advgetopt.conf",
    4876            1 :             SNAP_CATCH2_NAMESPACE::g_config_filename.c_str(),
    4877              :             "advgetopt.ini",
    4878            1 :             save_config_filename.c_str(),
    4879              :             "user.config",
    4880            1 :             SNAP_CATCH2_NAMESPACE::g_config_project_filename.c_str(),
    4881              :             nullptr
    4882            1 :         };
    4883              : 
    4884            1 :         advgetopt::options_environment options;
    4885            1 :         options.f_project_name = "config_writable_filenames";
    4886            1 :         options.f_options = options_list;
    4887            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4888            1 :         options.f_configuration_files = configuration_files;
    4889            1 :         options.f_configuration_filename = "advgetopt.conf";
    4890            1 :         options.f_configuration_directories = nullptr;
    4891            1 :         options.f_help_header = "Usage: test usage: %w";
    4892            1 :         options.f_help_footer = "Percent Configuration Files: %w";
    4893            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4894            1 :         options.f_version = "2.0.1-%w";
    4895            1 :         options.f_license = "MIT-%w";
    4896            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %w";
    4897            1 :         options.f_build_date = "Jun  4 2019 %w";
    4898            1 :         options.f_build_time = "23:02:36 %w";
    4899              : 
    4900            1 :         advgetopt::getopt opt(options, argc, argv);
    4901              : 
    4902            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4903              : 
    4904            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4905              : advgetopt::breakup_line(
    4906              :               "Usage: test usage: "
    4907              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    4908              :             + ", "
    4909              :             + save_config_project_filename
    4910              :         , 0
    4911              :         , advgetopt::get_screen_width())
    4912              : + advgetopt::format_usage_string(
    4913              :               "--verbose", "inform you of what we're currently working on: "
    4914              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    4915              :             + ", "
    4916              :             + save_config_project_filename + "."
    4917              :         , 30
    4918              :         , advgetopt::get_screen_width()) + "\n"
    4919              : + advgetopt::breakup_line(
    4920              :               "Percent Configuration Files: "
    4921              :             + SNAP_CATCH2_NAMESPACE::g_config_project_filename
    4922              :             + ", "
    4923              :             + save_config_project_filename
    4924              :         , 0
    4925              :         , advgetopt::get_screen_width())
    4926              :                 );
    4927            1 :     }
    4928            4 :     CATCH_END_SECTION()
    4929              : 
    4930            4 :     CATCH_START_SECTION("help_string_writable_configuration_files: percent writable configuration files (nullptr)")
    4931              :     {
    4932            1 :         const advgetopt::option options_list[] =
    4933              :         {
    4934              :             advgetopt::define_option(
    4935              :                   advgetopt::Name("verbose")
    4936              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4937              :                 , advgetopt::Help("inform you of what we're currently working on: %w.")
    4938              :             ),
    4939              :             advgetopt::end_options()
    4940              :         };
    4941            1 :         char const * cargv[] =
    4942              :         {
    4943              :             "tests/unittests/usage",
    4944              :             "--verbose",
    4945              :             nullptr
    4946              :         };
    4947            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4948            1 :         char ** argv = const_cast<char **>(cargv);
    4949              : 
    4950            1 :         advgetopt::options_environment options;
    4951            1 :         options.f_project_name = "unittest";
    4952            1 :         options.f_options = options_list;
    4953            1 :         options.f_options_files_directory = "/etc/advgetopt";
    4954            1 :         options.f_configuration_files = nullptr;
    4955            1 :         options.f_configuration_filename = "advgetopt.conf";
    4956            1 :         options.f_configuration_directories = nullptr;
    4957            1 :         options.f_help_header = "Usage: test usage: %w";
    4958            1 :         options.f_help_footer = "Percent Configuration Files: %w";
    4959            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    4960            1 :         options.f_version = "2.0.1-%w";
    4961            1 :         options.f_license = "MIT-%w";
    4962            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %w";
    4963            1 :         options.f_build_date = "Jun  4 2019 %w";
    4964            1 :         options.f_build_time = "23:02:36 %w";
    4965              : 
    4966            1 :         advgetopt::getopt opt(options, argc, argv);
    4967              : 
    4968            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    4969            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    4970              : "Usage: test usage: \n"
    4971              : "   --verbose                  inform you of what we're currently working on: .\n"
    4972              : "\n"
    4973              : "Percent Configuration Files: \n"
    4974              :                 );
    4975            1 :     }
    4976            4 :     CATCH_END_SECTION()
    4977              : 
    4978            4 :     CATCH_START_SECTION("help_string_writable_configuration_files: percent writable configuration files (empty array)")
    4979              :     {
    4980            1 :         const advgetopt::option options_list[] =
    4981              :         {
    4982              :             advgetopt::define_option(
    4983              :                   advgetopt::Name("verbose")
    4984              :                 , advgetopt::Flags(advgetopt::standalone_command_flags<>())
    4985              :                 , advgetopt::Help("inform you of what we're currently working on: %w.")
    4986              :             ),
    4987              :             advgetopt::end_options()
    4988              :         };
    4989            1 :         char const * cargv[] =
    4990              :         {
    4991              :             "tests/unittests/usage",
    4992              :             "--verbose",
    4993              :             nullptr
    4994              :         };
    4995            1 :         int const argc = sizeof(cargv) / sizeof(cargv[0]) - 1;
    4996            1 :         char ** argv = const_cast<char **>(cargv);
    4997              : 
    4998            1 :         const char * const configuration_files[] =
    4999              :         {
    5000              :             nullptr
    5001              :         };
    5002              : 
    5003            1 :         advgetopt::options_environment options;
    5004            1 :         options.f_project_name = "unittest";
    5005            1 :         options.f_options = options_list;
    5006            1 :         options.f_options_files_directory = "/etc/advgetopt";
    5007            1 :         options.f_configuration_files = configuration_files;
    5008            1 :         options.f_configuration_filename = "advgetopt.conf";
    5009            1 :         options.f_configuration_directories = nullptr;
    5010            1 :         options.f_help_header = "Usage: test usage: %w";
    5011            1 :         options.f_help_footer = "Percent Configuration Files: %w";
    5012            1 :         options.f_environment_variable_name = "ADVGETOPT_TEST_OPTIONS";
    5013            1 :         options.f_version = "2.0.1-%w";
    5014            1 :         options.f_license = "MIT-%w";
    5015            1 :         options.f_copyright = "Copyright (c) 2019  Made to Order Software Corp. -- All Rights Reserved %w";
    5016            1 :         options.f_build_date = "Jun  4 2019 %w";
    5017            1 :         options.f_build_time = "23:02:36 %w";
    5018              : 
    5019            1 :         advgetopt::getopt opt(options, argc, argv);
    5020              : 
    5021            1 :         CATCH_REQUIRE(advgetopt::GETOPT_FLAG_SHOW_MOST == 0);
    5022            3 :         CATCH_REQUIRE_LONG_STRING(opt.usage(),
    5023              : "Usage: test usage: \n"
    5024              : "   --verbose                  inform you of what we're currently working on: .\n"
    5025              : "\n"
    5026              : "Percent Configuration Files: \n"
    5027              :                 );
    5028            1 :     }
    5029            4 :     CATCH_END_SECTION()
    5030            4 : }
    5031              : 
    5032              : 
    5033              : 
    5034              : 
    5035            3 : CATCH_TEST_CASE("invalid_group_for_find_group", "[getopt][usage][config][invalid]")
    5036              : {
    5037            3 :     CATCH_START_SECTION("invalid_group_for_find_group: find_group() with invalid flags")
    5038              :     {
    5039           33 :         for(int idx(0); idx < 32; ++idx)
    5040              :         {
    5041           32 :             advgetopt::flag_t const invalid_group(1UL << idx);
    5042           32 :             if((invalid_group & ~advgetopt::GETOPT_FLAG_GROUP_MASK) == 0)
    5043              :             {
    5044              :                 // this is a valid group, skip
    5045              :                 //
    5046            3 :                 continue;
    5047              :             }
    5048              : 
    5049           29 :             advgetopt::group_description const groups[] =
    5050              :             {
    5051              :                 advgetopt::define_group(
    5052              :                       advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_COMMANDS)
    5053              :                 ),
    5054              :                 advgetopt::define_group(
    5055              :                       advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_OPTIONS)
    5056              :                 ),
    5057              :                 advgetopt::end_groups()
    5058              :             };
    5059              : 
    5060              : 
    5061           29 :             advgetopt::options_environment options;
    5062           29 :             options.f_project_name = "unittest";
    5063           29 :             options.f_groups = groups;
    5064           29 :             advgetopt::getopt opt(options);
    5065              : 
    5066           87 :             CATCH_REQUIRE_THROWS_MATCHES(
    5067              :                       opt.find_group(invalid_group)
    5068              :                     , advgetopt::getopt_logic_error
    5069              :                     , Catch::Matchers::ExceptionMessage(
    5070              :                                   "getopt_logic_error: group parameter must represent a valid group."));
    5071           29 :         }
    5072              :     }
    5073            3 :     CATCH_END_SECTION()
    5074              : 
    5075            3 :     CATCH_START_SECTION("invalid_group_for_find_group: find_group() with GETOPT_FLAG_GROUP_NONE")
    5076              :     {
    5077            1 :         advgetopt::group_description const groups[] =
    5078              :         {
    5079              :             advgetopt::define_group(
    5080              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_COMMANDS)
    5081              :             ),
    5082              :             advgetopt::define_group(
    5083              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_OPTIONS)
    5084              :             ),
    5085              :             advgetopt::end_groups()
    5086              :         };
    5087              : 
    5088            1 :         advgetopt::options_environment options;
    5089            1 :         options.f_project_name = "unittest";
    5090            1 :         options.f_groups = groups;
    5091            1 :         advgetopt::getopt opt(options);
    5092              : 
    5093            3 :         CATCH_REQUIRE_THROWS_MATCHES(
    5094              :                   opt.find_group(advgetopt::GETOPT_FLAG_GROUP_NONE)
    5095              :                 , advgetopt::getopt_logic_error
    5096              :                 , Catch::Matchers::ExceptionMessage(
    5097              :                               "getopt_logic_error: group NONE cannot be assigned a name so you cannot search for it."));
    5098            1 :     }
    5099            3 :     CATCH_END_SECTION()
    5100              : 
    5101            3 :     CATCH_START_SECTION("invalid_group_for_find_group: find_group() with invalid group definitions")
    5102              :     {
    5103              :         // define groups without name nor description
    5104              :         // (later the define_group() will err at compile time on those
    5105              :         // so we'll have to switch to a "manual" definition instead to
    5106              :         // verify that this indeed fails as expected.)
    5107              :         //
    5108            1 :         advgetopt::group_description const groups[] =
    5109              :         {
    5110              :             advgetopt::define_group(
    5111              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_COMMANDS)
    5112              :             ),
    5113              :             advgetopt::define_group(
    5114              :                   advgetopt::GroupNumber(advgetopt::GETOPT_FLAG_GROUP_OPTIONS)
    5115              :             ),
    5116              :             advgetopt::end_groups()
    5117              :         };
    5118              : 
    5119            1 :         advgetopt::options_environment options;
    5120            1 :         options.f_project_name = "unittest";
    5121            1 :         options.f_groups = groups;
    5122            1 :         advgetopt::getopt opt(options);
    5123              : 
    5124            3 :         CATCH_REQUIRE_THROWS_MATCHES(
    5125              :                   opt.find_group(advgetopt::GETOPT_FLAG_GROUP_COMMANDS)
    5126              :                 , advgetopt::getopt_logic_error
    5127              :                 , Catch::Matchers::ExceptionMessage(
    5128              :                               "getopt_logic_error: at least one of a group name or description must be defined (a non-empty string)."));
    5129              : 
    5130            3 :         CATCH_REQUIRE_THROWS_MATCHES(
    5131              :                   opt.find_group(advgetopt::GETOPT_FLAG_GROUP_OPTIONS)
    5132              :                 , advgetopt::getopt_logic_error
    5133              :                 , Catch::Matchers::ExceptionMessage(
    5134              :                               "getopt_logic_error: at least one of a group name or description must be defined (a non-empty string)."));
    5135            1 :     }
    5136            3 :     CATCH_END_SECTION()
    5137            3 : }
    5138              : 
    5139              : 
    5140              : 
    5141              : 
    5142              : 
    5143              : 
    5144              : 
    5145              : 
    5146              : // vim: ts=4 sw=4 et
        

Generated by: LCOV version 2.0-1

Snap C++ | List of projects | List of versions