LCOV - code coverage report
Current view: top level - tests - catch_usage.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1705 1705 100.0 %
Date: 2021-09-08 17:05:25 Functions: 19 19 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13