LCOV - code coverage report
Current view: top level - tests - usage.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1772 1772 100.0 %
Date: 2019-07-15 03:11:49 Functions: 19 19 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.12