Commit 6b7f6a7480554e183c31005a9a504c8151a21ad1

Authored by Philip Top
Committed by Henry Schreiner
1 parent 0c3020b9

Value initialization (#416)

* work on the flags book chapter and making sure the values are initialized properly.

* Fix initialization of values used in flags or options

* update some formatting and more brace initialization

* update more formatting and fix a incorrect initializer

* more formatting and some error fixes

* more formatting

* Small formatting fix

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
book/chapters/flags.md
... ... @@ -7,7 +7,7 @@ The most basic addition to a command line program is a flag. This is simply some
7 7 The simplest way to add a flag is probably a boolean flag:
8 8  
9 9 ```cpp
10   -bool my_flag;
  10 +bool my_flag{false};
11 11 app.add_flag("-f", my_flag, "Optional description");
12 12 ```
13 13  
... ... @@ -19,12 +19,38 @@ This will bind the flag `-f` to the boolean `my_flag`. After the parsing step, `
19 19 If you want to allow multiple flags, simply use any integer-like instead of a bool:
20 20  
21 21 ```cpp
22   -int my_flag;
  22 +int my_flag{0};
23 23 app.add_flag("-f", my_flag, "Optional description");
24 24 ```
25 25  
26 26 After the parsing step, `my_flag` will contain the number of times this flag was found on the command line, including 0 if not found.
27 27  
  28 +## Arbitrary type flags
  29 +
  30 +CLI11 allows the type of the variable to assign to in the `add_flag` function to be any supported type. This is particularly useful in combination with specifying default values for flags. The allowed types include bool, int, float, vector, enum, or string-like.
  31 +
  32 +### Default Flag Values
  33 +
  34 +Flag options specified through the `add_flag*` functions allow a syntax for the option names to default particular options to a false value or any other value if some flags are passed. For example:
  35 +
  36 +```cpp
  37 +app.add_flag("--flag,!--no-flag",result,"help for flag");
  38 +```
  39 +
  40 +specifies that if `--flag` is passed on the command line result will be true or contain a value of 1. If `--no-flag` is
  41 +passed `result` will contain false or -1 if `result` is a signed integer type, or 0 if it is an unsigned type. An
  42 +alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`; this is equivalent to the previous
  43 +example. This also works for short form options `"-f,!-n"` or `"-f,-n{false}"`. If `variable_to_bind_to` is anything but an integer value the
  44 +default behavior is to take the last value given, while if `variable_to_bind_to` is an integer type the behavior will be to sum
  45 +all the given arguments and return the result. This can be modified if needed by changing the `multi_option_policy` on each flag (this is not inherited).
  46 +The default value can be any value. For example if you wished to define a numerical flag:
  47 +
  48 +```cpp
  49 +app.add_flag("-1{1},-2{2},-3{3}",result,"numerical flag")
  50 +```
  51 +
  52 +using any of those flags on the command line will result in the specified number in the output. Similar things can be done for string values, and enumerations, as long as the default value can be converted to the given type.
  53 +
28 54 ## Pure flags
29 55  
30 56 Every command that starts with `add_`, such as the flag commands, return a pointer to the internally stored `CLI::Option` that describes your addition. If you prefer, you can capture this pointer and use it, and that allows you to skip adding a variable to bind to entirely:
... ... @@ -52,7 +78,7 @@ The name string, the first item of every `add_` method, can contain as many shor
52 78 If you want to make an option case insensitive, you can use the `->ignore_case()` method on the `CLI::Option` to do that. For example,
53 79  
54 80 ```cpp
55   -bool flag;
  81 +bool flag{false};
56 82 app.add_flag("--flag", flag)
57 83 ->ignore_case();
58 84 ```
... ...
book/chapters/options.md
... ... @@ -5,14 +5,14 @@ The most versatile addition to a command line program is a option. This is like
5 5  
6 6  
7 7 ```cpp
8   -int int_option;
  8 +int int_option{0};
9 9 app.add_option("-i", int_option, "Optional description");
10 10 ```
11 11  
12 12 This will bind the option `-i` to the integer `int_option`. On the command line, a single value that can be converted to an integer will be expected. Non-integer results will fail. If that option is not given, CLI11 will not touch the initial value. This allows you to set up defaults by simply setting your value beforehand. If you want CLI11 to display your default value, you can add the optional final argument `true` when you add the option. If you do not add this, you do not even need your option value to be printable[^1].
13 13  
14 14 ```cpp
15   -int int_option = 0;
  15 +int int_option{0};
16 16 app.add_option("-i", int_option, "Optional description", true);
17 17 ```
18 18  
... ... @@ -138,7 +138,7 @@ Besides `add_option` and `add_flag`, there are several special ways to create op
138 138 You can add a set with `add_set`, where you give a variable to set and a `std::set` of choices to pick from. There also is a `add_set_ignore_case` version which ignores case when set matching. If you use an existing set instead of an inline one, you can edit the set after adding it and changes will be reflected in the set checking and help message.
139 139  
140 140 ```cpp
141   -int val;
  141 +int val{0};
142 142 app.add_set("--even", val, {0,2,4,6,8});
143 143 ```
144 144  
... ... @@ -147,7 +147,7 @@ app.add_set(&quot;--even&quot;, val, {0,2,4,6,8});
147 147 You can also add a complex number. This type just needs to support a `(T x, T y)` constructor and be printable. You can also pass one extra argument that will set the label of the type; by default it is "COMPLEX".
148 148  
149 149 ```cpp
150   -std::complex<float> val;
  150 +std::complex<float> val{0.0F,0.0F};
151 151 app.add_complex("--cplx", val);
152 152 ```
153 153  
... ... @@ -197,7 +197,7 @@ app.add_option(&quot;--opt&quot;,val,&quot;description&quot;);
197 197 gets into the complicated cases where the type size is now 3. and the expected max is set to a large number and `allow_extra_args` is set to true. In this case at least 3 arguments are required to follow the option, and subsequent groups must come in groups of three, otherwise an error will result.
198 198  
199 199 ```cpp
200   -bool val;
  200 +bool val{false};
201 201 app.add_flag("--opt",val,"description");
202 202 ```
203 203  
... ...
examples/digit_args.cpp
... ... @@ -4,7 +4,7 @@
4 4 int main(int argc, char **argv) {
5 5 CLI::App app;
6 6  
7   - int val;
  7 + int val{0};
8 8 // add a set of flags with default values associate with them
9 9 app.add_flag("-1{1},-2{2},-3{3},-4{4},-5{5},-6{6}, -7{7}, -8{8}, -9{9}", val, "compression level");
10 10  
... ...
examples/groups.cpp
... ... @@ -11,10 +11,10 @@ int main(int argc, char **argv) {
11 11 std::string file;
12 12 CLI::Option *opt = app.add_option("-f,--file,file", file, "File name")->required()->group("Important");
13 13  
14   - int count;
  14 + int count{0};
15 15 CLI::Option *copt = app.add_flag("-c,--count", count, "Counter")->required()->group("Important");
16 16  
17   - double value; // = 3.14;
  17 + double value{0.0}; // = 3.14;
18 18 app.add_option("-d,--double", value, "Some Value")->group("Other");
19 19  
20 20 try {
... ...
examples/option_groups.cpp
... ... @@ -9,9 +9,9 @@ int main(int argc, char **argv) {
9 9  
10 10 auto format = app.add_option_group("output_format", "formatting type for output");
11 11 auto target = app.add_option_group("output target", "target location for the output");
12   - bool csv = false;
13   - bool human = false;
14   - bool binary = false;
  12 + bool csv{false};
  13 + bool human{false};
  14 + bool binary{false};
15 15 format->add_flag("--csv", csv, "specify the output in csv format");
16 16 format->add_flag("--human", human, "specify the output in human readable text format");
17 17 format->add_flag("--binary", binary, "specify the output in binary format");
... ...
examples/positional_arity.cpp
... ... @@ -8,7 +8,7 @@ int main(int argc, char **argv) {
8 8  
9 9 auto numbers = app.add_option_group("numbers", "specify key numbers");
10 10 auto files = app.add_option_group("files", "specify files");
11   - int num1 = -1, num2 = -1;
  11 + int num1{-1}, num2{-1};
12 12 numbers->add_option("num1", num1, "first number");
13 13 numbers->add_option("num2", num2, "second number");
14 14 std::string file1, file2;
... ...
examples/positional_validation.cpp
... ... @@ -6,7 +6,7 @@ int main(int argc, char **argv) {
6 6  
7 7 CLI::App app("test for positional validation");
8 8  
9   - int num1 = -1, num2 = -1;
  9 + int num1{-1}, num2{-1};
10 10 app.add_option("num1", num1, "first number")->check(CLI::Number);
11 11 app.add_option("num2", num2, "second number")->check(CLI::Number);
12 12 std::string file1, file2;
... ...
examples/ranges.cpp
... ... @@ -10,7 +10,7 @@ int main(int argc, char **argv) {
10 10 app.add_option("--range,-R", range, "A range")->expected(-2);
11 11  
12 12 auto ogroup = app.add_option_group("min_max_step", "set the min max and step");
13   - int min, max, step = 1;
  13 + int min{0}, max{0}, step{1};
14 14 ogroup->add_option("--min,-m", min, "The minimum")->required();
15 15 ogroup->add_option("--max,-M", max, "The maximum")->required();
16 16 ogroup->add_option("--step,-s", step, "The step", true);
... ...
examples/shapes.cpp
... ... @@ -9,7 +9,7 @@ int main(int argc, char **argv) {
9 9 app.set_help_all_flag("--help-all");
10 10 auto circle = app.add_subcommand("circle", "draw a circle")->immediate_callback();
11 11 double radius{0.0};
12   - int circle_counter = 0;
  12 + int circle_counter{0};
13 13 circle->callback([&radius, &circle_counter] {
14 14 ++circle_counter;
15 15 std::cout << "circle" << circle_counter << " with radius " << radius << std::endl;
... ... @@ -20,7 +20,7 @@ int main(int argc, char **argv) {
20 20 auto rect = app.add_subcommand("rectangle", "draw a rectangle")->immediate_callback();
21 21 double edge1{0.0};
22 22 double edge2{0.0};
23   - int rect_counter = 0;
  23 + int rect_counter{0};
24 24 rect->callback([&edge1, &edge2, &rect_counter] {
25 25 ++rect_counter;
26 26 if(edge2 == 0) {
... ...
examples/simple.cpp
... ... @@ -9,13 +9,13 @@ int main(int argc, char **argv) {
9 9 std::string file;
10 10 CLI::Option *opt = app.add_option("-f,--file,file", file, "File name");
11 11  
12   - int count;
  12 + int count{0};
13 13 CLI::Option *copt = app.add_option("-c,--count", count, "Counter");
14 14  
15   - int v;
  15 + int v{0};
16 16 CLI::Option *flag = app.add_flag("--flag", v, "Some flag that can be passed multiple times");
17 17  
18   - double value; // = 3.14;
  18 + double value{0.0}; // = 3.14;
19 19 app.add_option("-d,--double", value, "Some Value");
20 20  
21 21 CLI11_PARSE(app, argc, argv);
... ...
examples/subcom_partitioned.cpp
... ... @@ -13,11 +13,11 @@ int main(int argc, char **argv) {
13 13 std::string file;
14 14 CLI::Option *opt = impOpt->add_option("-f,--file,file", file, "File name")->required();
15 15  
16   - int count;
  16 + int count{0};
17 17 CLI::Option *copt = impOpt->add_flag("-c,--count", count, "Counter")->required();
18 18  
19 19 CLI::App_p otherOpt = std::make_shared<CLI::App>("Other");
20   - double value; // = 3.14;
  20 + double value{0.0}; // = 3.14;
21 21 otherOpt->add_option("-d,--double", value, "Some Value");
22 22  
23 23 // add the subapps to the main one
... ...
examples/validators.cpp
... ... @@ -9,7 +9,7 @@ int main(int argc, char **argv) {
9 9 std::string file;
10 10 app.add_option("-f,--file,file", file, "File name")->check(CLI::ExistingFile);
11 11  
12   - int count;
  12 + int count{0};
13 13 app.add_option("-v,--value", count, "Value in range")->check(CLI::Range(3, 6));
14 14 CLI11_PARSE(app, argc, argv);
15 15  
... ...
tests/AppTest.cpp
... ... @@ -141,7 +141,7 @@ TEST_F(TApp, RequireOptionsError) {
141 141 }
142 142  
143 143 TEST_F(TApp, BoolFlagOverride) {
144   - bool val;
  144 + bool val{false};
145 145 auto flg = app.add_flag("--this,--that", val);
146 146  
147 147 app.parse("--this");
... ... @@ -161,7 +161,7 @@ TEST_F(TApp, BoolFlagOverride) {
161 161 }
162 162  
163 163 TEST_F(TApp, OneFlagRef) {
164   - int ref;
  164 + int ref{0};
165 165 app.add_flag("-c,--count", ref);
166 166 args = {"--count"};
167 167 run();
... ... @@ -171,7 +171,7 @@ TEST_F(TApp, OneFlagRef) {
171 171 }
172 172  
173 173 TEST_F(TApp, OneFlagRefValue) {
174   - int ref;
  174 + int ref{0};
175 175 app.add_flag("-c,--count", ref);
176 176 args = {"--count=7"};
177 177 run();
... ... @@ -181,7 +181,7 @@ TEST_F(TApp, OneFlagRefValue) {
181 181 }
182 182  
183 183 TEST_F(TApp, OneFlagRefValueFalse) {
184   - int ref;
  184 + int ref{0};
185 185 auto flg = app.add_flag("-c,--count", ref);
186 186 args = {"--count=false"};
187 187 run();
... ... @@ -201,7 +201,7 @@ TEST_F(TApp, OneFlagRefValueFalse) {
201 201 }
202 202  
203 203 TEST_F(TApp, FlagNegation) {
204   - int ref;
  204 + int ref{0};
205 205 auto flg = app.add_flag("-c,--count,--ncount{false}", ref);
206 206 args = {"--count", "-c", "--ncount"};
207 207 EXPECT_FALSE(flg->check_fname("count"));
... ... @@ -214,7 +214,7 @@ TEST_F(TApp, FlagNegation) {
214 214 }
215 215  
216 216 TEST_F(TApp, FlagNegationShortcutNotation) {
217   - int ref;
  217 + int ref{0};
218 218 app.add_flag("-c,--count{true},!--ncount", ref);
219 219 args = {"--count=TRUE", "-c", "--ncount"};
220 220 run();
... ... @@ -225,7 +225,7 @@ TEST_F(TApp, FlagNegationShortcutNotation) {
225 225 }
226 226  
227 227 TEST_F(TApp, FlagNegationShortcutNotationInvalid) {
228   - int ref;
  228 + int ref{0};
229 229 app.add_flag("-c,--count,!--ncount", ref);
230 230 args = {"--ncount=happy"};
231 231 EXPECT_THROW(run(), CLI::ConversionError);
... ... @@ -418,7 +418,7 @@ TEST_F(TApp, OneStringFlagLike) {
418 418 }
419 419  
420 420 TEST_F(TApp, OneIntFlagLike) {
421   - int val;
  421 + int val{0};
422 422 auto opt = app.add_option("-i", val)->expected(0, 1);
423 423 args = {"-i"};
424 424 run();
... ... @@ -433,7 +433,7 @@ TEST_F(TApp, OneIntFlagLike) {
433 433 }
434 434  
435 435 TEST_F(TApp, TogetherInt) {
436   - int i;
  436 + int i{0};
437 437 app.add_option("-i,--int", i);
438 438 args = {"-i4"};
439 439 run();
... ... @@ -445,7 +445,7 @@ TEST_F(TApp, TogetherInt) {
445 445 }
446 446  
447 447 TEST_F(TApp, SepInt) {
448   - int i;
  448 + int i{0};
449 449 app.add_option("-i,--int", i);
450 450 args = {"-i", "4"};
451 451 run();
... ... @@ -475,7 +475,7 @@ TEST_F(TApp, OneStringFunction) {
475 475 }
476 476  
477 477 TEST_F(TApp, doubleFunction) {
478   - double res;
  478 + double res{0.0};
479 479 app.add_option_function<double>("--val", [&res](double val) { res = std::abs(val + 54); });
480 480 args = {"--val", "-354.356"};
481 481 run();
... ... @@ -596,7 +596,7 @@ TEST_F(TApp, LotsOfFlags) {
596 596  
597 597 TEST_F(TApp, NumberFlags) {
598 598  
599   - int val;
  599 + int val{0};
600 600 app.add_flag("-1{1},-2{2},-3{3},-4{4},-5{5},-6{6}, -7{7}, -8{8}, -9{9}", val);
601 601  
602 602 args = {"-7"};
... ... @@ -607,7 +607,7 @@ TEST_F(TApp, NumberFlags) {
607 607  
608 608 TEST_F(TApp, DisableFlagOverrideTest) {
609 609  
610   - int val;
  610 + int val{0};
611 611 auto opt = app.add_flag("--1{1},--2{2},--3{3},--4{4},--5{5},--6{6}, --7{7}, --8{8}, --9{9}", val);
612 612 EXPECT_FALSE(opt->get_disable_flag_override());
613 613 opt->disable_flag_override();
... ... @@ -649,9 +649,9 @@ TEST_F(TApp, LotsOfFlagsSingleStringExtraSpace) {
649 649  
650 650 TEST_F(TApp, BoolAndIntFlags) {
651 651  
652   - bool bflag;
653   - int iflag;
654   - unsigned int uflag;
  652 + bool bflag{false};
  653 + int iflag{0};
  654 + unsigned int uflag{0};
655 655  
656 656 app.add_flag("-b", bflag);
657 657 app.add_flag("-i", iflag);
... ... @@ -677,7 +677,7 @@ TEST_F(TApp, BoolAndIntFlags) {
677 677 }
678 678  
679 679 TEST_F(TApp, FlagLikeOption) {
680   - bool val = false;
  680 + bool val{false};
681 681 auto opt = app.add_option("--flag", val)->type_size(0)->default_str("true");
682 682 args = {"--flag"};
683 683 run();
... ... @@ -693,7 +693,7 @@ TEST_F(TApp, FlagLikeOption) {
693 693 }
694 694  
695 695 TEST_F(TApp, FlagLikeIntOption) {
696   - int val = -47;
  696 + int val{-47};
697 697 auto opt = app.add_option("--flag", val)->expected(0, 1);
698 698 // normally some default value should be set, but this test is for some paths in the validators checks to skip
699 699 // validation on empty string if nothing is expected
... ... @@ -713,7 +713,7 @@ TEST_F(TApp, FlagLikeIntOption) {
713 713 }
714 714  
715 715 TEST_F(TApp, BoolOnlyFlag) {
716   - bool bflag;
  716 + bool bflag{false};
717 717 app.add_flag("-b", bflag)->multi_option_policy(CLI::MultiOptionPolicy::Throw);
718 718  
719 719 args = {"-b"};
... ... @@ -725,7 +725,7 @@ TEST_F(TApp, BoolOnlyFlag) {
725 725 }
726 726  
727 727 TEST_F(TApp, BoolOption) {
728   - bool bflag;
  728 + bool bflag{false};
729 729 app.add_option("-b", bflag);
730 730  
731 731 args = {"-b", "false"};
... ... @@ -752,7 +752,7 @@ TEST_F(TApp, BoolOption) {
752 752  
753 753 TEST_F(TApp, ShortOpts) {
754 754  
755   - unsigned long long funnyint;
  755 + unsigned long long funnyint{0};
756 756 std::string someopt;
757 757 app.add_flag("-z", funnyint);
758 758 app.add_option("-y", someopt);
... ... @@ -772,7 +772,7 @@ TEST_F(TApp, ShortOpts) {
772 772  
773 773 TEST_F(TApp, TwoParamTemplateOpts) {
774 774  
775   - double funnyint;
  775 + double funnyint{0.0};
776 776 auto opt = app.add_option<double, unsigned int>("-y", funnyint);
777 777  
778 778 args = {"-y", "32"};
... ... @@ -793,7 +793,7 @@ TEST_F(TApp, TwoParamTemplateOpts) {
793 793  
794 794 TEST_F(TApp, DefaultOpts) {
795 795  
796   - int i = 3;
  796 + int i{3};
797 797 std::string s = "HI";
798 798  
799 799 app.add_option("-i,i", i);
... ... @@ -971,7 +971,7 @@ TEST_F(TApp, ComplexOptMulti) {
971 971 }
972 972  
973 973 TEST_F(TApp, MissingValueNonRequiredOpt) {
974   - int count;
  974 + int count{0};
975 975 app.add_option("-c,--count", count);
976 976  
977 977 args = {"-c"};
... ... @@ -1191,7 +1191,7 @@ TEST_F(TApp, RequiredPositionalVector) {
1191 1191 // Tests positionals at end
1192 1192 TEST_F(TApp, RequiredPositionalValidation) {
1193 1193 std::vector<std::string> sources;
1194   - int dest;
  1194 + int dest; // required
1195 1195 std::string d2;
1196 1196 app.add_option("src", sources);
1197 1197 app.add_option("dest", dest)->required()->check(CLI::PositiveNumber);
... ... @@ -1432,7 +1432,7 @@ TEST_F(TApp, RequiredFlags) {
1432 1432  
1433 1433 TEST_F(TApp, CallbackFlags) {
1434 1434  
1435   - std::int64_t value = 0;
  1435 + std::int64_t value{0};
1436 1436  
1437 1437 auto func = [&value](std::int64_t x) { value = x; };
1438 1438  
... ... @@ -1454,7 +1454,7 @@ TEST_F(TApp, CallbackFlags) {
1454 1454  
1455 1455 TEST_F(TApp, CallbackBoolFlags) {
1456 1456  
1457   - bool value = false;
  1457 + bool value{false};
1458 1458  
1459 1459 auto func = [&value]() { value = true; };
1460 1460  
... ... @@ -1534,7 +1534,7 @@ TEST_F(TApp, CallbackFlagsFalseShortcut) {
1534 1534 #if __cplusplus >= 201402L || _MSC_VER >= 1900
1535 1535 TEST_F(TApp, CallbackFlagsAuto) {
1536 1536  
1537   - std::int64_t value = 0;
  1537 + std::int64_t value{0};
1538 1538  
1539 1539 auto func = [&value](std::int64_t x) { value = x; };
1540 1540  
... ... @@ -1593,7 +1593,7 @@ TEST_F(TApp, ForcedPositional) {
1593 1593  
1594 1594 TEST_F(TApp, MixedPositionals) {
1595 1595  
1596   - int positional_int;
  1596 + int positional_int{0};
1597 1597 std::string positional_string;
1598 1598 app.add_option("posit1,--posit1", positional_int, "");
1599 1599 app.add_option("posit2,--posit2", positional_string, "");
... ... @@ -1626,7 +1626,7 @@ TEST_F(TApp, BigPositional) {
1626 1626 TEST_F(TApp, Reset) {
1627 1627  
1628 1628 app.add_flag("--simple");
1629   - double doub;
  1629 + double doub{0.0};
1630 1630 app.add_option("-d,--double", doub);
1631 1631  
1632 1632 args = {"--simple", "--double", "1.2"};
... ... @@ -1850,7 +1850,7 @@ TEST_F(TApp, VectorIndexedValidator) {
1850 1850  
1851 1851 TEST_F(TApp, DefaultedResult) {
1852 1852 std::string sval = "NA";
1853   - int ival;
  1853 + int ival{0};
1854 1854 auto opts = app.add_option("--string", sval)->capture_default_str();
1855 1855 auto optv = app.add_option("--val", ival);
1856 1856 args = {};
... ... @@ -2095,7 +2095,7 @@ TEST_F(TApp, Env) {
2095 2095  
2096 2096 put_env("CLI11_TEST_ENV_TMP", "2");
2097 2097  
2098   - int val = 1;
  2098 + int val{1};
2099 2099 CLI::Option *vopt = app.add_option("--tmp", val)->envname("CLI11_TEST_ENV_TMP");
2100 2100  
2101 2101 run();
... ... @@ -2111,7 +2111,7 @@ TEST_F(TApp, Env) {
2111 2111 }
2112 2112  
2113 2113 TEST_F(TApp, RangeInt) {
2114   - int x = 0;
  2114 + int x{0};
2115 2115 app.add_option("--one", x)->check(CLI::Range(3, 6));
2116 2116  
2117 2117 args = {"--one=1"};
... ... @@ -2132,7 +2132,7 @@ TEST_F(TApp, RangeInt) {
2132 2132  
2133 2133 TEST_F(TApp, RangeDouble) {
2134 2134  
2135   - double x = 0;
  2135 + double x{0.0};
2136 2136 /// Note that this must be a double in Range, too
2137 2137 app.add_option("--one", x)->check(CLI::Range(3.0, 6.0));
2138 2138  
... ... @@ -2157,7 +2157,7 @@ TEST_F(TApp, AllowExtras) {
2157 2157  
2158 2158 app.allow_extras();
2159 2159  
2160   - bool val = true;
  2160 + bool val{true};
2161 2161 app.add_flag("-f", val);
2162 2162  
2163 2163 args = {"-x", "-f"};
... ... @@ -2217,8 +2217,8 @@ TEST_F(TApp, AllowExtrasCascadeDirect) {
2217 2217 EXPECT_EQ(app.remaining(), std::vector<std::string>({"-x", "45", "-f", "27"}));
2218 2218  
2219 2219 CLI::App capp{"cascade_program"};
2220   - int v1 = 0;
2221   - int v2 = 0;
  2220 + int v1{0};
  2221 + int v2{0};
2222 2222 capp.add_option("-x", v1);
2223 2223 capp.add_option("-f", v2);
2224 2224  
... ... @@ -2229,8 +2229,8 @@ TEST_F(TApp, AllowExtrasCascadeDirect) {
2229 2229  
2230 2230 TEST_F(TApp, AllowExtrasArgModify) {
2231 2231  
2232   - int v1 = 0;
2233   - int v2 = 0;
  2232 + int v1{0};
  2233 + int v2{0};
2234 2234 app.allow_extras();
2235 2235 app.add_option("-f", v2);
2236 2236 args = {"27", "-f", "45", "-x"};
... ... @@ -2308,7 +2308,7 @@ TEST_F(TApp, FallthroughParents) {
2308 2308 }
2309 2309  
2310 2310 TEST_F(TApp, OptionWithDefaults) {
2311   - int someint = 2;
  2311 + int someint{2};
2312 2312 app.add_option("-a", someint)->capture_default_str();
2313 2313  
2314 2314 args = {"-a1", "-a2"};
... ... @@ -2587,7 +2587,7 @@ TEST_F(TApp, BeforeRequirements) {
2587 2587 // #209
2588 2588 TEST_F(TApp, CustomUserSepParse) {
2589 2589  
2590   - std::vector<int> vals = {1, 2, 3};
  2590 + std::vector<int> vals{1, 2, 3};
2591 2591 args = {"--idx", "1,2,3"};
2592 2592 auto opt = app.add_option("--idx", vals)->delimiter(',');
2593 2593 run();
... ... @@ -2631,7 +2631,7 @@ TEST_F(TApp, BadUserSepParse) {
2631 2631 // #209
2632 2632 TEST_F(TApp, CustomUserSepParse2) {
2633 2633  
2634   - std::vector<int> vals = {1, 2, 3};
  2634 + std::vector<int> vals{1, 2, 3};
2635 2635 args = {"--idx", "1,2,"};
2636 2636 auto opt = app.add_option("--idx", vals)->delimiter(',');
2637 2637 run();
... ... @@ -2646,7 +2646,7 @@ TEST_F(TApp, CustomUserSepParse2) {
2646 2646  
2647 2647 TEST_F(TApp, CustomUserSepParseFunction) {
2648 2648  
2649   - std::vector<int> vals = {1, 2, 3};
  2649 + std::vector<int> vals{1, 2, 3};
2650 2650 args = {"--idx", "1,2,3"};
2651 2651 app.add_option_function<std::vector<int>>("--idx", [&vals](std::vector<int> v) { vals = std::move(v); })
2652 2652 ->delimiter(',');
... ...
tests/ConfigFileTest.cpp
... ... @@ -439,7 +439,7 @@ TEST_F(TApp, IniSuccessOnUnknownOption) {
439 439 out << "two=99" << std::endl;
440 440 }
441 441  
442   - int two = 0;
  442 + int two{0};
443 443 app.add_option("--two", two);
444 444 run();
445 445 EXPECT_EQ(99, two);
... ... @@ -459,7 +459,7 @@ TEST_F(TApp, IniGetRemainingOption) {
459 459 out << "two=99" << std::endl;
460 460 }
461 461  
462   - int two = 0;
  462 + int two{0};
463 463 app.add_option("--two", two);
464 464 ASSERT_NO_THROW(run());
465 465 std::vector<std::string> ExpectedRemaining = {ExtraOption};
... ... @@ -477,7 +477,7 @@ TEST_F(TApp, IniGetNoRemaining) {
477 477 out << "two=99" << std::endl;
478 478 }
479 479  
480   - int two = 0;
  480 + int two{0};
481 481 app.add_option("--two", two);
482 482 ASSERT_NO_THROW(run());
483 483 EXPECT_EQ(app.remaining().size(), 0u);
... ... @@ -487,7 +487,7 @@ TEST_F(TApp, IniRequiredNoDefault) {
487 487  
488 488 app.set_config("--config")->required();
489 489  
490   - int two = 0;
  490 + int two{0};
491 491 app.add_option("--two", two);
492 492 ASSERT_THROW(run(), CLI::FileError);
493 493 }
... ... @@ -496,7 +496,7 @@ TEST_F(TApp, IniNotRequiredNoDefault) {
496 496  
497 497 app.set_config("--config");
498 498  
499   - int two = 0;
  499 + int two{0};
500 500 app.add_option("--two", two);
501 501 ASSERT_NO_THROW(run());
502 502 }
... ... @@ -523,7 +523,7 @@ TEST_F(TApp, IniRequiredbadConfigurator) {
523 523  
524 524 app.set_config("--config", tmpini)->required();
525 525 app.config_formatter(std::make_shared<EvilConfig>());
526   - int two = 0;
  526 + int two{0};
527 527 app.add_option("--two", two);
528 528 ASSERT_THROW(run(), CLI::FileError);
529 529 }
... ... @@ -541,7 +541,7 @@ TEST_F(TApp, IniNotRequiredbadConfigurator) {
541 541  
542 542 app.set_config("--config", tmpini);
543 543 app.config_formatter(std::make_shared<EvilConfig>());
544   - int two = 0;
  544 + int two{0};
545 545 app.add_option("--two", two);
546 546 ASSERT_NO_THROW(run());
547 547 }
... ... @@ -567,7 +567,7 @@ TEST_F(TApp, IniNotRequiredNotDefault) {
567 567 out << "three=4" << std::endl;
568 568 }
569 569  
570   - int one = 0, two = 0, three = 0;
  570 + int one{0}, two{0}, three{0};
571 571 app.add_option("--one", one);
572 572 app.add_option("--two", two);
573 573 app.add_option("--three", three);
... ... @@ -616,7 +616,7 @@ TEST_F(TApp, IniOverwrite) {
616 616 app.set_config("--config", orig);
617 617 // Make sure this can be overwritten
618 618 app.set_config("--conf", next);
619   - int two = 7;
  619 + int two{7};
620 620 app.add_option("--two", two);
621 621  
622 622 run();
... ... @@ -637,7 +637,7 @@ TEST_F(TApp, IniRequired) {
637 637 out << "three=3" << std::endl;
638 638 }
639 639  
640   - int one = 0, two = 0, three = 0;
  640 + int one{0}, two{0}, three{0};
641 641 app.add_option("--one", one)->required();
642 642 app.add_option("--two", two)->required();
643 643 app.add_option("--three", three)->required();
... ... @@ -726,7 +726,7 @@ TEST_F(TApp, ColonValueSep) {
726 726 out << "three:3\n";
727 727 }
728 728  
729   - int two, three;
  729 + int two{0}, three{0};
730 730 app.add_option("--two", two);
731 731 app.add_option("--three", three);
732 732  
... ... @@ -830,7 +830,7 @@ TEST_F(TApp, IniLayered) {
830 830 out << "subsubcom.val=3" << std::endl;
831 831 }
832 832  
833   - int one = 0, two = 0, three = 0;
  833 + int one{0}, two{0}, three{0};
834 834 app.add_option("--val", one);
835 835 auto subcom = app.add_subcommand("subcom");
836 836 subcom->add_option("--val", two);
... ... @@ -863,7 +863,7 @@ TEST_F(TApp, IniLayeredDotSection) {
863 863 out << "val=3" << std::endl;
864 864 }
865 865  
866   - int one = 0, two = 0, three = 0;
  866 + int one{0}, two{0}, three{0};
867 867 app.add_option("--val", one);
868 868 auto subcom = app.add_subcommand("subcom");
869 869 subcom->add_option("--val", two);
... ... @@ -895,7 +895,7 @@ TEST_F(TApp, IniSubcommandConfigurable) {
895 895 out << "subsubcom.val=3" << std::endl;
896 896 }
897 897  
898   - int one = 0, two = 0, three = 0;
  898 + int one{0}, two{0}, three{0};
899 899 app.add_option("--val", one);
900 900 auto subcom = app.add_subcommand("subcom");
901 901 subcom->configurable();
... ... @@ -929,7 +929,7 @@ TEST_F(TApp, IniSubcommandConfigurablePreParse) {
929 929 out << "subsubcom.val=3" << std::endl;
930 930 }
931 931  
932   - int one = 0, two = 0, three = 0, four = 0;
  932 + int one{0}, two{0}, three{0}, four{0};
933 933 app.add_option("--val", one);
934 934 auto subcom = app.add_subcommand("subcom");
935 935 auto subcom2 = app.add_subcommand("subcom2");
... ... @@ -971,7 +971,7 @@ TEST_F(TApp, IniSubcommandConfigurableParseComplete) {
971 971 out << "val=3" << std::endl;
972 972 }
973 973  
974   - int one = 0, two = 0, three = 0, four = 0;
  974 + int one{0}, two{0}, three{0}, four{0};
975 975 app.add_option("--val", one);
976 976 auto subcom = app.add_subcommand("subcom");
977 977 auto subcom2 = app.add_subcommand("subcom2");
... ... @@ -1018,7 +1018,7 @@ TEST_F(TApp, IniSubcommandMultipleSections) {
1018 1018 out << "val=4" << std::endl;
1019 1019 }
1020 1020  
1021   - int one = 0, two = 0, three = 0, four = 0;
  1021 + int one{0}, two{0}, three{0}, four{0};
1022 1022 app.add_option("--val", one);
1023 1023 auto subcom = app.add_subcommand("subcom");
1024 1024 auto subcom2 = app.add_subcommand("subcom2");
... ... @@ -1062,7 +1062,7 @@ TEST_F(TApp, DuplicateSubcommandCallbacks) {
1062 1062 }
1063 1063  
1064 1064 auto foo = app.add_subcommand("foo");
1065   - int count = 0;
  1065 + int count{0};
1066 1066 foo->callback([&count]() { ++count; });
1067 1067 foo->immediate_callback();
1068 1068 EXPECT_TRUE(foo->get_immediate_callback());
... ... @@ -1092,7 +1092,7 @@ TEST_F(TApp, IniConfigurable) {
1092 1092 TempFile tmpini{"TestIniTmp.ini"};
1093 1093  
1094 1094 app.set_config("--config", tmpini);
1095   - bool value;
  1095 + bool value{false};
1096 1096 app.add_flag("--val", value)->configurable(true);
1097 1097  
1098 1098 {
... ... @@ -1110,7 +1110,7 @@ TEST_F(TApp, IniNotConfigurable) {
1110 1110 TempFile tmpini{"TestIniTmp.ini"};
1111 1111  
1112 1112 app.set_config("--config", tmpini);
1113   - bool value;
  1113 + bool value{false};
1114 1114 app.add_flag("--val", value)->configurable(false);
1115 1115  
1116 1116 {
... ... @@ -1165,7 +1165,7 @@ TEST_F(TApp, IniFlagConvertFailure) {
1165 1165 out << "flag=moobook" << std::endl;
1166 1166 }
1167 1167 run();
1168   - bool result;
  1168 + bool result{false};
1169 1169 auto *opt = app.get_option("--flag");
1170 1170 EXPECT_THROW(opt->results(result), CLI::ConversionError);
1171 1171 std::string res;
... ... @@ -1177,7 +1177,7 @@ TEST_F(TApp, IniFlagNumbers) {
1177 1177  
1178 1178 TempFile tmpini{"TestIniTmp.ini"};
1179 1179  
1180   - bool boo;
  1180 + bool boo{false};
1181 1181 app.add_flag("--flag", boo);
1182 1182 app.set_config("--config", tmpini);
1183 1183  
... ... @@ -1194,7 +1194,7 @@ TEST_F(TApp, IniFlagDual) {
1194 1194  
1195 1195 TempFile tmpini{"TestIniTmp.ini"};
1196 1196  
1197   - bool boo;
  1197 + bool boo{false};
1198 1198 app.add_flag("--flag", boo);
1199 1199 app.set_config("--config", tmpini);
1200 1200  
... ... @@ -1210,7 +1210,7 @@ TEST_F(TApp, IniFlagText) {
1210 1210  
1211 1211 TempFile tmpini{"TestIniTmp.ini"};
1212 1212  
1213   - bool flag1, flag2, flag3, flag4;
  1213 + bool flag1{false}, flag2{false}, flag3{false}, flag4{false};
1214 1214 app.add_flag("--flag1", flag1);
1215 1215 app.add_flag("--flag2", flag2);
1216 1216 app.add_flag("--flag3", flag3);
... ... @@ -1246,8 +1246,8 @@ TEST_F(TApp, IniFlags) {
1246 1246 out << "five" << std::endl;
1247 1247 }
1248 1248  
1249   - int two;
1250   - bool three, four, five;
  1249 + int two{0};
  1250 + bool three{false}, four{false}, five{false};
1251 1251 app.add_flag("--two", two);
1252 1252 app.add_flag("--three", three);
1253 1253 app.add_flag("--four", four);
... ... @@ -1274,8 +1274,8 @@ TEST_F(TApp, IniFalseFlags) {
1274 1274 out << "five" << std::endl;
1275 1275 }
1276 1276  
1277   - int two;
1278   - bool three, four, five;
  1277 + int two{0};
  1278 + bool three{false}, four{false}, five{false};
1279 1279 app.add_flag("--two", two);
1280 1280 app.add_flag("--three", three);
1281 1281 app.add_flag("--four", four);
... ... @@ -1302,8 +1302,8 @@ TEST_F(TApp, IniFalseFlagsDef) {
1302 1302 out << "five" << std::endl;
1303 1303 }
1304 1304  
1305   - int two;
1306   - bool three, four, five;
  1305 + int two{0};
  1306 + bool three{false}, four{false}, five{false};
1307 1307 app.add_flag("--two{false}", two);
1308 1308 app.add_flag("--three", three);
1309 1309 app.add_flag("!--four", four);
... ... @@ -1329,8 +1329,8 @@ TEST_F(TApp, IniFalseFlagsDefDisableOverrideError) {
1329 1329 out << "five" << std::endl;
1330 1330 }
1331 1331  
1332   - int two;
1333   - bool four, five;
  1332 + int two{0};
  1333 + bool four{false}, five{false};
1334 1334 app.add_flag("--two{false}", two)->disable_flag_override();
1335 1335 app.add_flag("!--four", four);
1336 1336 app.add_flag("--five", five);
... ... @@ -1350,7 +1350,7 @@ TEST_F(TApp, IniFalseFlagsDefDisableOverrideSuccess) {
1350 1350 out << "val=15" << std::endl;
1351 1351 }
1352 1352  
1353   - int two, four, val;
  1353 + int two{0}, four{0}, val{0};
1354 1354 app.add_flag("--two{2}", two)->disable_flag_override();
1355 1355 app.add_flag("--four{4}", four)->disable_flag_override();
1356 1356 app.add_flag("--val", val);
... ... @@ -1364,7 +1364,7 @@ TEST_F(TApp, IniFalseFlagsDefDisableOverrideSuccess) {
1364 1364  
1365 1365 TEST_F(TApp, IniOutputSimple) {
1366 1366  
1367   - int v;
  1367 + int v{0};
1368 1368 app.add_option("--simple", v);
1369 1369  
1370 1370 args = {"--simple=3"};
... ... @@ -1377,7 +1377,7 @@ TEST_F(TApp, IniOutputSimple) {
1377 1377  
1378 1378 TEST_F(TApp, IniOutputNoConfigurable) {
1379 1379  
1380   - int v1, v2;
  1380 + int v1{0}, v2{0};
1381 1381 app.add_option("--simple", v1);
1382 1382 app.add_option("--noconf", v2)->configurable(false);
1383 1383  
... ... @@ -1433,7 +1433,7 @@ TEST_F(TApp, IniOutputGroups) {
1433 1433 TEST_F(TApp, IniOutputHiddenOptions) {
1434 1434 std::string flag1 = "flagnr1";
1435 1435 std::string flag2 = "flagnr2";
1436   - double val = 12.7;
  1436 + double val{12.7};
1437 1437 const std::string description1 = "First description.";
1438 1438 const std::string description2 = "Second description.";
1439 1439 app.add_flag("--" + flag1, description1)->group("group1");
... ... @@ -1470,7 +1470,7 @@ TEST_F(TApp, IniOutputMultiLineDescription) {
1470 1470 TEST_F(TApp, IniOutputOptionGroup) {
1471 1471 std::string flag1 = "flagnr1";
1472 1472 std::string flag2 = "flagnr2";
1473   - double val = 12.7;
  1473 + double val{12.7};
1474 1474 const std::string description1 = "First description.";
1475 1475 const std::string description2 = "Second description.";
1476 1476 app.add_flag("--" + flag1, description1)->group("group1");
... ... @@ -1539,7 +1539,7 @@ TEST_F(TApp, IniOutputVectorCustom) {
1539 1539  
1540 1540 TEST_F(TApp, IniOutputFlag) {
1541 1541  
1542   - int v, q;
  1542 + int v{0}, q{0};
1543 1543 app.add_option("--simple", v);
1544 1544 app.add_flag("--nothing");
1545 1545 app.add_flag("--onething");
... ... @@ -1561,7 +1561,7 @@ TEST_F(TApp, IniOutputFlag) {
1561 1561  
1562 1562 TEST_F(TApp, IniOutputSet) {
1563 1563  
1564   - int v;
  1564 + int v{0};
1565 1565 app.add_option("--simple", v)->check(CLI::IsMember({1, 2, 3}));
1566 1566  
1567 1567 args = {"--simple=2"};
... ... @@ -1574,7 +1574,7 @@ TEST_F(TApp, IniOutputSet) {
1574 1574  
1575 1575 TEST_F(TApp, IniOutputDefault) {
1576 1576  
1577   - int v = 7;
  1577 + int v{7};
1578 1578 app.add_option("--simple", v, "", true);
1579 1579  
1580 1580 run();
... ... @@ -1726,7 +1726,7 @@ TEST_F(TApp, StopReadingConfigOnClear) {
1726 1726 out << "volume=1" << std::endl;
1727 1727 }
1728 1728  
1729   - int volume = 0;
  1729 + int volume{0};
1730 1730 app.add_option("--volume", volume, "volume1");
1731 1731  
1732 1732 run();
... ...
tests/CreationTest.cpp
... ... @@ -164,12 +164,12 @@ TEST_F(TApp, MultipleSubcomNoMatchingInplaceUnderscore2) {
164 164 TEST_F(TApp, IncorrectConstructionFlagPositional1) { EXPECT_THROW(app.add_flag("cat"), CLI::IncorrectConstruction); }
165 165  
166 166 TEST_F(TApp, IncorrectConstructionFlagPositional2) {
167   - int x;
  167 + int x{0};
168 168 EXPECT_THROW(app.add_flag("cat", x), CLI::IncorrectConstruction);
169 169 }
170 170  
171 171 TEST_F(TApp, IncorrectConstructionFlagPositional3) {
172   - bool x;
  172 + bool x{false};
173 173 EXPECT_THROW(app.add_flag("cat", x), CLI::IncorrectConstruction);
174 174 }
175 175  
... ... @@ -220,7 +220,7 @@ TEST_F(TApp, CheckName) {
220 220 auto long2 = app.add_flag("--Long2");
221 221 auto short1 = app.add_flag("-a");
222 222 auto short2 = app.add_flag("-B");
223   - int x, y;
  223 + int x{0}, y{0};
224 224 auto pos1 = app.add_option("pos1", x);
225 225 auto pos2 = app.add_option("pOs2", y);
226 226  
... ... @@ -248,7 +248,7 @@ TEST_F(TApp, CheckNameNoCase) {
248 248 auto long2 = app.add_flag("--Long2")->ignore_case();
249 249 auto short1 = app.add_flag("-a")->ignore_case();
250 250 auto short2 = app.add_flag("-B")->ignore_case();
251   - int x, y;
  251 + int x{0}, y{0};
252 252 auto pos1 = app.add_option("pos1", x)->ignore_case();
253 253 auto pos2 = app.add_option("pOs2", y)->ignore_case();
254 254  
... ... @@ -275,7 +275,7 @@ TEST_F(TApp, CheckNameNoUnderscore) {
275 275 auto long1 = app.add_flag("--longoption1")->ignore_underscore();
276 276 auto long2 = app.add_flag("--long_option2")->ignore_underscore();
277 277  
278   - int x, y;
  278 + int x{0}, y{0};
279 279 auto pos1 = app.add_option("pos_option_1", x)->ignore_underscore();
280 280 auto pos2 = app.add_option("posoption2", y)->ignore_underscore();
281 281  
... ... @@ -306,7 +306,7 @@ TEST_F(TApp, CheckNameNoCaseNoUnderscore) {
306 306 auto long1 = app.add_flag("--LongoptioN1")->ignore_underscore()->ignore_case();
307 307 auto long2 = app.add_flag("--long_Option2")->ignore_case()->ignore_underscore();
308 308  
309   - int x, y;
  309 + int x{0}, y{0};
310 310 auto pos1 = app.add_option("pos_Option_1", x)->ignore_underscore()->ignore_case();
311 311 auto pos2 = app.add_option("posOption2", y)->ignore_case()->ignore_underscore();
312 312  
... ... @@ -334,7 +334,7 @@ TEST_F(TApp, CheckNameNoCaseNoUnderscore) {
334 334 }
335 335  
336 336 TEST_F(TApp, PreSpaces) {
337   - int x;
  337 + int x{0};
338 338 auto myapp = app.add_option(" -a, --long, other", x);
339 339  
340 340 EXPECT_TRUE(myapp->check_lname("long"));
... ... @@ -343,7 +343,7 @@ TEST_F(TApp, PreSpaces) {
343 343 }
344 344  
345 345 TEST_F(TApp, AllSpaces) {
346   - int x;
  346 + int x{0};
347 347 auto myapp = app.add_option(" -a , --long , other ", x);
348 348  
349 349 EXPECT_TRUE(myapp->check_lname("long"));
... ... @@ -355,7 +355,7 @@ TEST_F(TApp, OptionFromDefaults) {
355 355 app.option_defaults()->required();
356 356  
357 357 // Options should remember defaults
358   - int x;
  358 + int x{0};
359 359 auto opt = app.add_option("--simple", x);
360 360 EXPECT_TRUE(opt->get_required());
361 361  
... ... @@ -411,7 +411,7 @@ TEST_F(TApp, OptionFromDefaultsSubcommands) {
411 411 }
412 412  
413 413 TEST_F(TApp, GetNameCheck) {
414   - int x;
  414 + int x{0};
415 415 auto a = app.add_flag("--that");
416 416 auto b = app.add_flag("-x");
417 417 auto c = app.add_option("pos", x);
... ... @@ -523,7 +523,7 @@ TEST_F(TApp, SubcommandMinMax) {
523 523 }
524 524  
525 525 TEST_F(TApp, GetOptionList) {
526   - int two;
  526 + int two{0};
527 527 auto flag = app.add_flag("--one");
528 528 auto opt = app.add_option("--two", two);
529 529  
... ... @@ -704,7 +704,7 @@ TEST(ValidatorTests, ValidatorDefaults) {
704 704  
705 705 class Unstreamable {
706 706 private:
707   - int x_ = -1;
  707 + int x_{-1};
708 708  
709 709 public:
710 710 Unstreamable() = default;
... ...
tests/FormatterTest.cpp
... ... @@ -49,7 +49,7 @@ TEST(Formatter, OptCustomize) {
49 49 optfmt->label("REQUIRED", "(MUST HAVE)");
50 50 app.formatter(optfmt);
51 51  
52   - int v;
  52 + int v{0};
53 53 app.add_option("--opt", v, "Something")->required();
54 54  
55 55 std::string help = app.help();
... ... @@ -69,7 +69,7 @@ TEST(Formatter, OptCustomizeSimple) {
69 69 app.get_formatter()->column_width(25);
70 70 app.get_formatter()->label("REQUIRED", "(MUST HAVE)");
71 71  
72   - int v;
  72 + int v{0};
73 73 app.add_option("--opt", v, "Something")->required();
74 74  
75 75 std::string help = app.help();
... ... @@ -89,10 +89,10 @@ TEST(Formatter, FalseFlagExample) {
89 89 app.get_formatter()->column_width(25);
90 90 app.get_formatter()->label("REQUIRED", "(MUST HAVE)");
91 91  
92   - int v;
  92 + int v{0};
93 93 app.add_flag("--opt,!--no_opt", v, "Something");
94 94  
95   - bool flag;
  95 + bool flag{false};
96 96 app.add_flag("!-O,--opt2,--no_opt2{false}", flag, "Something else");
97 97  
98 98 std::string help = app.help();
... ... @@ -180,7 +180,7 @@ TEST(Formatter, NamelessSubInGroup) {
180 180 CLI::App *sub = app.add_subcommand("", "This subcommand");
181 181 CLI::App *sub2 = app.add_subcommand("sub2", "subcommand2");
182 182 sub->add_flag("--insub", "MyFlag");
183   - int val;
  183 + int val{0};
184 184 sub2->add_option("pos", val, "positional");
185 185 sub->group("group1");
186 186 sub2->group("group1");
... ...
tests/HelpTest.cpp
... ... @@ -330,7 +330,7 @@ TEST(THelp, Needs) {
330 330 TEST(THelp, NeedsPositional) {
331 331 CLI::App app{"My prog"};
332 332  
333   - int x, y;
  333 + int x{0}, y{0};
334 334  
335 335 CLI::Option *op1 = app.add_option("op1", x, "one");
336 336 app.add_option("op2", y, "two")->needs(op1);
... ... @@ -355,7 +355,7 @@ TEST(THelp, Excludes) {
355 355 TEST(THelp, ExcludesPositional) {
356 356 CLI::App app{"My prog"};
357 357  
358   - int x, y;
  358 + int x{0}, y{0};
359 359  
360 360 CLI::Option *op1 = app.add_option("op1", x);
361 361 app.add_option("op2", y)->excludes(op1);
... ... @@ -381,7 +381,7 @@ TEST(THelp, ManualSetters) {
381 381  
382 382 CLI::App app{"My prog"};
383 383  
384   - int x = 1;
  384 + int x{1};
385 385  
386 386 CLI::Option *op1 = app.add_option("--op", x);
387 387 op1->default_str("12");
... ... @@ -418,7 +418,7 @@ TEST(THelp, ManualSetterOverFunction) {
418 418  
419 419 CLI::App app{"My prog"};
420 420  
421   - int x = 1;
  421 + int x{1};
422 422  
423 423 CLI::Option *op1 = app.add_option("--op1", x)->check(CLI::IsMember({1, 2}));
424 424 CLI::Option *op2 = app.add_option("--op2", x)->transform(CLI::IsMember({1, 2}));
... ... @@ -650,7 +650,7 @@ TEST(THelp, CustomHelp) {
650 650  
651 651 TEST(THelp, NextLineShouldBeAlignmentInMultilineDescription) {
652 652 CLI::App app;
653   - int i;
  653 + int i{0};
654 654 const std::string first{"first line"};
655 655 const std::string second{"second line"};
656 656 app.add_option("-i,--int", i, first + "\n" + second);
... ... @@ -663,7 +663,7 @@ TEST(THelp, NextLineShouldBeAlignmentInMultilineDescription) {
663 663 TEST(THelp, NiceName) {
664 664 CLI::App app;
665 665  
666   - int x;
  666 + int x{0};
667 667 auto long_name = app.add_option("-s,--long,-q,--other,that", x);
668 668 auto short_name = app.add_option("more,-x,-y", x);
669 669 auto positional = app.add_option("posit", x);
... ... @@ -878,7 +878,7 @@ TEST(THelp, SetDescriptionAfterCreation) {
878 878 TEST(THelp, AccessOptionDescription) {
879 879 CLI::App app{};
880 880  
881   - int x;
  881 + int x{0};
882 882 auto opt = app.add_option("-a,--alpha", x, "My description goes here");
883 883  
884 884 EXPECT_EQ(opt->get_description(), "My description goes here");
... ... @@ -887,7 +887,7 @@ TEST(THelp, AccessOptionDescription) {
887 887 TEST(THelp, SetOptionDescriptionAfterCreation) {
888 888 CLI::App app{};
889 889  
890   - int x;
  890 + int x{0};
891 891 auto opt = app.add_option("-a,--alpha", x);
892 892 opt->description("My description goes here");
893 893  
... ... @@ -898,7 +898,7 @@ TEST(THelp, SetOptionDescriptionAfterCreation) {
898 898 TEST(THelp, CleanNeeds) {
899 899 CLI::App app;
900 900  
901   - int x;
  901 + int x{0};
902 902 auto a_name = app.add_option("-a,--alpha", x);
903 903 app.add_option("-b,--boo", x)->needs(a_name);
904 904  
... ... @@ -910,7 +910,7 @@ TEST(THelp, CleanNeeds) {
910 910 TEST(THelp, RequiredPrintout) {
911 911 CLI::App app;
912 912  
913   - int x;
  913 + int x{0};
914 914 app.add_option("-a,--alpha", x)->required();
915 915  
916 916 EXPECT_THAT(app.help(), HasSubstr(" REQUIRED"));
... ... @@ -936,8 +936,8 @@ TEST(THelp, ValidatorsText) {
936 936 CLI::App app;
937 937  
938 938 std::string filename;
939   - int x;
940   - unsigned int y;
  939 + int x{0};
  940 + unsigned int y{0};
941 941 app.add_option("--f1", filename)->check(CLI::ExistingFile);
942 942 app.add_option("--f3", x)->check(CLI::Range(1, 4));
943 943 app.add_option("--f4", y)->check(CLI::Range(12));
... ... @@ -1032,7 +1032,7 @@ TEST(THelp, ChangingSet) {
1032 1032 CLI::App app;
1033 1033  
1034 1034 std::set<int> vals{1, 2, 3};
1035   - int val;
  1035 + int val{0};
1036 1036 app.add_option("--val", val)->check(CLI::IsMember(&vals));
1037 1037  
1038 1038 std::string help = app.help();
... ... @@ -1053,7 +1053,7 @@ TEST(THelp, ChangingSetDefaulted) {
1053 1053 CLI::App app;
1054 1054  
1055 1055 std::set<int> vals{1, 2, 3};
1056   - int val = 2;
  1056 + int val{2};
1057 1057 app.add_option("--val", val, "")->check(CLI::IsMember(&vals))->capture_default_str();
1058 1058  
1059 1059 std::string help = app.help();
... ...
tests/HelpersTest.cpp
... ... @@ -105,7 +105,7 @@ TEST(String, InvalidName) {
105 105 }
106 106  
107 107 TEST(StringTools, Modify) {
108   - int cnt = 0;
  108 + int cnt{0};
109 109 std::string newString = CLI::detail::find_and_modify("======", "=", [&cnt](std::string &str, std::size_t index) {
110 110 if((++cnt) % 2 == 0) {
111 111 str[index] = ':';
... ... @@ -444,8 +444,8 @@ TEST(Validators, ProgramNameSplit) {
444 444 }
445 445  
446 446 TEST(CheckedMultiply, Int) {
447   - int a = 10;
448   - int b = -20;
  447 + int a{10};
  448 + int b{-20};
449 449 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
450 450 ASSERT_EQ(a, -200);
451 451  
... ... @@ -562,55 +562,55 @@ TEST(CheckedMultiply, SizeT) {
562 562 }
563 563  
564 564 TEST(CheckedMultiply, Float) {
565   - float a = 10;
566   - float b = 20;
  565 + float a{10.0F};
  566 + float b{20.0F};
567 567 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
568 568 ASSERT_FLOAT_EQ(a, 200);
569 569  
570   - a = 0;
571   - b = 20;
  570 + a = 0.0F;
  571 + b = 20.0F;
572 572 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
573 573 ASSERT_FLOAT_EQ(a, 0);
574 574  
575 575 a = INFINITY;
576   - b = 20;
  576 + b = 20.0F;
577 577 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
578 578 ASSERT_FLOAT_EQ(a, INFINITY);
579 579  
580   - a = 2;
  580 + a = 2.0F;
581 581 b = -INFINITY;
582 582 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
583 583 ASSERT_FLOAT_EQ(a, -INFINITY);
584 584  
585   - a = std::numeric_limits<float>::max() / 100;
586   - b = 1;
  585 + a = std::numeric_limits<float>::max() / 100.0F;
  586 + b = 1.0F;
587 587 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
588   - ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100);
  588 + ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100.0F);
589 589  
590   - a = std::numeric_limits<float>::max() / 100;
591   - b = 99;
  590 + a = std::numeric_limits<float>::max() / 100.0F;
  591 + b = 99.0F;
592 592 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
593   - ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100 * 99);
  593 + ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100.0F * 99.0F);
594 594  
595   - a = std::numeric_limits<float>::max() / 100;
  595 + a = std::numeric_limits<float>::max() / 100.0F;
596 596 b = 101;
597 597 ASSERT_FALSE(CLI::detail::checked_multiply(a, b));
598   - ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100);
  598 + ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100.0F);
599 599  
600   - a = std::numeric_limits<float>::max() / 100;
  600 + a = std::numeric_limits<float>::max() / 100.0F;
601 601 b = -99;
602 602 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
603   - ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100 * -99);
  603 + ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100.0F * -99.0F);
604 604  
605   - a = std::numeric_limits<float>::max() / 100;
  605 + a = std::numeric_limits<float>::max() / 100.0F;
606 606 b = -101;
607 607 ASSERT_FALSE(CLI::detail::checked_multiply(a, b));
608   - ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100);
  608 + ASSERT_FLOAT_EQ(a, std::numeric_limits<float>::max() / 100.0F);
609 609 }
610 610  
611 611 TEST(CheckedMultiply, Double) {
612   - double a = 10;
613   - double b = 20;
  612 + double a{10.0F};
  613 + double b{20.0F};
614 614 ASSERT_TRUE(CLI::detail::checked_multiply(a, b));
615 615 ASSERT_DOUBLE_EQ(a, 200);
616 616  
... ... @@ -1014,7 +1014,7 @@ TEST(Types, LexicalCastEnum) {
1014 1014  
1015 1015 EXPECT_FALSE(CLI::detail::lexical_cast("invalid", output));
1016 1016 enum class t2 : std::uint64_t { enum1 = 65, enum2 = 45667, enum3 = 9999999999999 };
1017   - t2 output2;
  1017 + t2 output2{t2::enum2};
1018 1018 EXPECT_TRUE(CLI::detail::lexical_cast("65", output2));
1019 1019 EXPECT_EQ(output2, t2::enum1);
1020 1020  
... ... @@ -1026,7 +1026,7 @@ TEST(Types, LexicalCastEnum) {
1026 1026  
1027 1027 TEST(Types, LexicalConversionDouble) {
1028 1028 CLI::results_t input = {"9.12"};
1029   - long double x;
  1029 + long double x{0.0};
1030 1030 bool res = CLI::detail::lexical_conversion<long double, double>(input, x);
1031 1031 EXPECT_TRUE(res);
1032 1032 EXPECT_FLOAT_EQ((float)9.12, (float)x);
... ... @@ -1038,7 +1038,7 @@ TEST(Types, LexicalConversionDouble) {
1038 1038  
1039 1039 TEST(Types, LexicalConversionDoubleTuple) {
1040 1040 CLI::results_t input = {"9.12"};
1041   - std::tuple<double> x;
  1041 + std::tuple<double> x{0.0};
1042 1042 bool res = CLI::detail::lexical_conversion<decltype(x), decltype(x)>(input, x);
1043 1043 EXPECT_TRUE(res);
1044 1044 EXPECT_DOUBLE_EQ(9.12, std::get<0>(x));
... ... @@ -1073,7 +1073,7 @@ static_assert(CLI::detail::is_tuple_like&lt;std::tuple&lt;double, int, double&gt;&gt;::value
1073 1073 TEST(Types, LexicalConversionTuple2) {
1074 1074 CLI::results_t input = {"9.12", "19"};
1075 1075  
1076   - std::tuple<double, int> x;
  1076 + std::tuple<double, int> x{0.0, 0};
1077 1077 static_assert(CLI::detail::is_tuple_like<decltype(x)>::value,
1078 1078 "tuple type must have is_tuple_like trait to be true");
1079 1079 bool res = CLI::detail::lexical_conversion<decltype(x), decltype(x)>(input, x);
... ...
tests/NewParseTest.cpp
... ... @@ -269,7 +269,7 @@ template &lt;&gt; bool lexical_cast&lt;std::complex&lt;double&gt;&gt;(const std::string &amp;input, st
269 269 R"(([+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?)\s*([+-]\s*(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?)[ji]*)");
270 270  
271 271 std::smatch m;
272   - double x = 0.0, y = 0.0;
  272 + double x{0.0}, y{0.0};
273 273 bool worked;
274 274 std::regex_search(input, m, creg);
275 275 if(m.size() == 9) {
... ...
tests/OptionGroupTest.cpp
... ... @@ -23,11 +23,11 @@ TEST_F(TApp, BasicOptionGroup) {
23 23  
24 24 TEST_F(TApp, BasicOptionGroupExact) {
25 25 auto ogroup = app.add_option_group("clusters");
26   - int res;
  26 + int res{0};
27 27 ogroup->add_option("--test1", res);
28 28 ogroup->add_option("--test2", res);
29 29 ogroup->add_option("--test3", res);
30   - int val2;
  30 + int val2{0};
31 31 app.add_option("--option", val2);
32 32 ogroup->require_option(1);
33 33 args = {"--test1", "5"};
... ... @@ -47,11 +47,11 @@ TEST_F(TApp, BasicOptionGroupExact) {
47 47  
48 48 TEST_F(TApp, BasicOptionGroupExactTooMany) {
49 49 auto ogroup = app.add_option_group("clusters");
50   - int res;
  50 + int res{0};
51 51 ogroup->add_option("--test1", res);
52 52 ogroup->add_option("--test2", res);
53 53 ogroup->add_option("--test3", res);
54   - int val2;
  54 + int val2{0};
55 55 app.add_option("--option", val2);
56 56 ogroup->require_option(10);
57 57 args = {"--test1", "5"};
... ... @@ -60,11 +60,11 @@ TEST_F(TApp, BasicOptionGroupExactTooMany) {
60 60  
61 61 TEST_F(TApp, BasicOptionGroupMinMax) {
62 62 auto ogroup = app.add_option_group("clusters");
63   - int res;
  63 + int res{0};
64 64 ogroup->add_option("--test1", res);
65 65 ogroup->add_option("--test2", res);
66 66 ogroup->add_option("--test3", res);
67   - int val2;
  67 + int val2{0};
68 68 app.add_option("--option", val2);
69 69 ogroup->require_option(1, 1);
70 70 args = {"--test1", "5"};
... ... @@ -84,11 +84,11 @@ TEST_F(TApp, BasicOptionGroupMinMax) {
84 84  
85 85 TEST_F(TApp, BasicOptionGroupMinMaxDifferent) {
86 86 auto ogroup = app.add_option_group("clusters");
87   - int res;
  87 + int res{0};
88 88 ogroup->add_option("--test1", res);
89 89 ogroup->add_option("--test2", res);
90 90 ogroup->add_option("--test3", res);
91   - int val2;
  91 + int val2{0};
92 92 app.add_option("--option", val2);
93 93 ogroup->require_option(1, 2);
94 94 args = {"--test1", "5"};
... ... @@ -112,11 +112,11 @@ TEST_F(TApp, BasicOptionGroupMinMaxDifferent) {
112 112  
113 113 TEST_F(TApp, BasicOptionGroupMinMaxDifferentReversed) {
114 114 auto ogroup = app.add_option_group("clusters");
115   - int res;
  115 + int res{0};
116 116 ogroup->add_option("--test1", res);
117 117 ogroup->add_option("--test2", res);
118 118 ogroup->add_option("--test3", res);
119   - int val2;
  119 + int val2{0};
120 120 app.add_option("--option", val2);
121 121 ogroup->require_option(2, 1);
122 122 EXPECT_EQ(ogroup->get_require_option_min(), 2u);
... ... @@ -144,7 +144,7 @@ TEST_F(TApp, BasicOptionGroupMinMaxDifferentReversed) {
144 144  
145 145 TEST_F(TApp, BasicOptionGroupMax) {
146 146 auto ogroup = app.add_option_group("clusters");
147   - int res;
  147 + int res{0};
148 148 ogroup->add_option("--test1", res);
149 149 ogroup->add_option("--test2", res);
150 150 ogroup->add_option("--test3", res);
... ... @@ -168,11 +168,11 @@ TEST_F(TApp, BasicOptionGroupMax) {
168 168  
169 169 TEST_F(TApp, BasicOptionGroupMax1) {
170 170 auto ogroup = app.add_option_group("clusters");
171   - int res;
  171 + int res{0};
172 172 ogroup->add_option("--test1", res);
173 173 ogroup->add_option("--test2", res);
174 174 ogroup->add_option("--test3", res);
175   - int val2;
  175 + int val2{0};
176 176 app.add_option("--option", val2);
177 177 ogroup->require_option(-1);
178 178 args = {"--test1", "5"};
... ... @@ -192,11 +192,11 @@ TEST_F(TApp, BasicOptionGroupMax1) {
192 192  
193 193 TEST_F(TApp, BasicOptionGroupMin) {
194 194 auto ogroup = app.add_option_group("clusters");
195   - int res;
  195 + int res{0};
196 196 ogroup->add_option("--test1", res);
197 197 ogroup->add_option("--test2", res);
198 198 ogroup->add_option("--test3", res);
199   - int val2;
  199 + int val2{0};
200 200 app.add_option("--option", val2);
201 201 ogroup->require_option();
202 202  
... ... @@ -213,11 +213,11 @@ TEST_F(TApp, BasicOptionGroupMin) {
213 213  
214 214 TEST_F(TApp, BasicOptionGroupExact2) {
215 215 auto ogroup = app.add_option_group("clusters");
216   - int res;
  216 + int res{0};
217 217 ogroup->add_option("--test1", res);
218 218 ogroup->add_option("--test2", res);
219 219 ogroup->add_option("--test3", res);
220   - int val2;
  220 + int val2{0};
221 221 app.add_option("--option", val2);
222 222 ogroup->require_option(2);
223 223  
... ... @@ -237,11 +237,11 @@ TEST_F(TApp, BasicOptionGroupExact2) {
237 237  
238 238 TEST_F(TApp, BasicOptionGroupMin2) {
239 239 auto ogroup = app.add_option_group("clusters");
240   - int res;
  240 + int res{0};
241 241 ogroup->add_option("--test1", res);
242 242 ogroup->add_option("--test2", res);
243 243 ogroup->add_option("--test3", res);
244   - int val2;
  244 + int val2{0};
245 245 app.add_option("--option", val2);
246 246 ogroup->require_option(2, 0);
247 247  
... ... @@ -258,11 +258,11 @@ TEST_F(TApp, BasicOptionGroupMin2) {
258 258  
259 259 TEST_F(TApp, BasicOptionGroupMinMoved) {
260 260  
261   - int res;
  261 + int res{0};
262 262 auto opt1 = app.add_option("--test1", res);
263 263 auto opt2 = app.add_option("--test2", res);
264 264 auto opt3 = app.add_option("--test3", res);
265   - int val2;
  265 + int val2{0};
266 266 app.add_option("--option", val2);
267 267  
268 268 auto ogroup = app.add_option_group("clusters");
... ... @@ -287,11 +287,11 @@ TEST_F(TApp, BasicOptionGroupMinMoved) {
287 287  
288 288 TEST_F(TApp, BasicOptionGroupMinMovedAsGroup) {
289 289  
290   - int res;
  290 + int res{0};
291 291 auto opt1 = app.add_option("--test1", res);
292 292 auto opt2 = app.add_option("--test2", res);
293 293 auto opt3 = app.add_option("--test3", res);
294   - int val2;
  294 + int val2{0};
295 295 app.add_option("--option", val2);
296 296  
297 297 auto ogroup = app.add_option_group("clusters");
... ... @@ -315,10 +315,10 @@ TEST_F(TApp, BasicOptionGroupMinMovedAsGroup) {
315 315  
316 316 TEST_F(TApp, BasicOptionGroupAddFailures) {
317 317  
318   - int res;
  318 + int res{0};
319 319 auto opt1 = app.add_option("--test1", res);
320 320 app.set_config("--config");
321   - int val2;
  321 + int val2{0};
322 322 app.add_option("--option", val2);
323 323  
324 324 auto ogroup = app.add_option_group("clusters");
... ... @@ -341,10 +341,10 @@ TEST_F(TApp, BasicOptionGroupAddFailures) {
341 341  
342 342 TEST_F(TApp, BasicOptionGroupScrewedUpMove) {
343 343  
344   - int res;
  344 + int res{0};
345 345 auto opt1 = app.add_option("--test1", res);
346 346 auto opt2 = app.add_option("--test2", res);
347   - int val2;
  347 + int val2{0};
348 348 app.add_option("--option", val2);
349 349  
350 350 auto ogroup = app.add_option_group("clusters");
... ...
tests/SetTest.cpp
... ... @@ -26,7 +26,7 @@ static_assert(CLI::detail::pair_adaptor&lt;std::map&lt;int, int&gt;&gt;::value == true, &quot;Sho
26 26 static_assert(CLI::detail::pair_adaptor<std::vector<std::pair<int, int>>>::value == true, "Should have pairs");
27 27  
28 28 TEST_F(TApp, SimpleMaps) {
29   - int value;
  29 + int value{0};
30 30 std::map<std::string, int> map = {{"one", 1}, {"two", 2}};
31 31 auto opt = app.add_option("-s,--set", value)->transform(CLI::Transformer(map));
32 32 args = {"-s", "one"};
... ... @@ -319,7 +319,7 @@ TEST_F(TApp, SetFromCharStarArrayVector) {
319 319 }
320 320  
321 321 TEST_F(TApp, OtherTypeSets) {
322   - int value;
  322 + int value{0};
323 323 std::vector<int> set = {2, 3, 4};
324 324 auto opt = app.add_option("--set", value)->check(CLI::IsMember(set));
325 325 args = {"--set", "3"};
... ... @@ -353,7 +353,7 @@ TEST_F(TApp, OtherTypeSets) {
353 353 }
354 354  
355 355 TEST_F(TApp, NumericalSets) {
356   - int value;
  356 + int value{0};
357 357 auto opt = app.add_option("-s,--set", value)->check(CLI::IsMember{std::set<int>({1, 2, 3})});
358 358 args = {"-s", "1"};
359 359 run();
... ... @@ -366,7 +366,7 @@ TEST_F(TApp, NumericalSets) {
366 366 // Converted original set tests
367 367  
368 368 TEST_F(TApp, SetWithDefaults) {
369   - int someint = 2;
  369 + int someint{2};
370 370 app.add_option("-a", someint, "", true)->check(CLI::IsMember({1, 2, 3, 4}));
371 371  
372 372 args = {"-a1", "-a2"};
... ... @@ -375,7 +375,7 @@ TEST_F(TApp, SetWithDefaults) {
375 375 }
376 376  
377 377 TEST_F(TApp, SetWithDefaultsConversion) {
378   - int someint = 2;
  378 + int someint{2};
379 379 app.add_option("-a", someint, "", true)->check(CLI::IsMember({1, 2, 3, 4}));
380 380  
381 381 args = {"-a", "hi"};
... ... @@ -442,7 +442,7 @@ TEST_F(TApp, InCaselessSetWithDefault) {
442 442  
443 443 TEST_F(TApp, InIntSet) {
444 444  
445   - int choice;
  445 + int choice{0};
446 446 app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3}));
447 447  
448 448 args = {"--quick", "2"};
... ... @@ -456,7 +456,7 @@ TEST_F(TApp, InIntSet) {
456 456  
457 457 TEST_F(TApp, InIntSetWindows) {
458 458  
459   - int choice;
  459 + int choice{0};
460 460 app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3}));
461 461 app.allow_windows_style_options();
462 462 args = {"/q", "2"};
... ... @@ -473,7 +473,7 @@ TEST_F(TApp, InIntSetWindows) {
473 473  
474 474 TEST_F(TApp, FailSet) {
475 475  
476   - int choice;
  476 + int choice{0};
477 477 app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3}));
478 478  
479 479 args = {"--quick", "3", "--quick=2"};
... ... @@ -485,7 +485,7 @@ TEST_F(TApp, FailSet) {
485 485  
486 486 TEST_F(TApp, FailMutableSet) {
487 487  
488   - int choice;
  488 + int choice{0};
489 489 auto vals = std::shared_ptr<std::set<int>>(new std::set<int>({1, 2, 3}));
490 490 app.add_option("-q,--quick", choice)->check(CLI::IsMember(vals));
491 491 app.add_option("-s,--slow", choice, "", true)->check(CLI::IsMember(vals));
... ...
tests/SubcommandTest.cpp
... ... @@ -192,7 +192,7 @@ TEST_F(TApp, DuplicateSubcommands) {
192 192 TEST_F(TApp, DuplicateSubcommandCallbacks) {
193 193  
194 194 auto foo = app.add_subcommand("foo");
195   - int count = 0;
  195 + int count{0};
196 196 foo->callback([&count]() { ++count; });
197 197 foo->immediate_callback();
198 198 EXPECT_TRUE(foo->get_immediate_callback());
... ... @@ -208,7 +208,7 @@ TEST_F(TApp, DuplicateSubcommandCallbacks) {
208 208 TEST_F(TApp, DuplicateSubcommandCallbacksValues) {
209 209  
210 210 auto foo = app.add_subcommand("foo");
211   - int val;
  211 + int val{0};
212 212 foo->add_option("--val", val);
213 213 std::vector<int> vals;
214 214 foo->callback([&vals, &val]() { vals.push_back(val); });
... ... @@ -231,7 +231,7 @@ TEST_F(TApp, Callbacks) {
231 231 auto sub1 = app.add_subcommand("sub1");
232 232 sub1->callback([]() { throw CLI::Success(); });
233 233 auto sub2 = app.add_subcommand("sub2");
234   - bool val = false;
  234 + bool val{false};
235 235 sub2->callback([&val]() { val = true; });
236 236  
237 237 args = {"sub2"};
... ... @@ -353,7 +353,7 @@ TEST_F(TApp, RuntimeErrorInCallback) {
353 353 }
354 354  
355 355 TEST_F(TApp, NoFallThroughOpts) {
356   - int val = 1;
  356 + int val{1};
357 357 app.add_option("--val", val);
358 358  
359 359 app.add_subcommand("sub");
... ... @@ -363,7 +363,7 @@ TEST_F(TApp, NoFallThroughOpts) {
363 363 }
364 364  
365 365 TEST_F(TApp, NoFallThroughPositionals) {
366   - int val = 1;
  366 + int val{1};
367 367 app.add_option("val", val);
368 368  
369 369 app.add_subcommand("sub");
... ... @@ -373,7 +373,7 @@ TEST_F(TApp, NoFallThroughPositionals) {
373 373 }
374 374  
375 375 TEST_F(TApp, NoFallThroughOptsWithTerminator) {
376   - int val = 1;
  376 + int val{1};
377 377 app.add_option("--val", val);
378 378  
379 379 app.add_subcommand("sub");
... ... @@ -384,7 +384,7 @@ TEST_F(TApp, NoFallThroughOptsWithTerminator) {
384 384 }
385 385  
386 386 TEST_F(TApp, NoFallThroughPositionalsWithTerminator) {
387   - int val = 1;
  387 + int val{1};
388 388 app.add_option("val", val);
389 389  
390 390 app.add_subcommand("sub");
... ... @@ -402,7 +402,7 @@ TEST_F(TApp, NoFallThroughPositionalsWithTerminator) {
402 402 TEST_F(TApp, NamelessSubComPositionals) {
403 403  
404 404 auto sub = app.add_subcommand();
405   - int val = 1;
  405 + int val{1};
406 406 sub->add_option("val", val);
407 407  
408 408 args = {"2"};
... ... @@ -515,7 +515,7 @@ TEST_F(TApp, Nameless4LayerDeepMulti) {
515 515  
516 516 TEST_F(TApp, FallThroughRegular) {
517 517 app.fallthrough();
518   - int val = 1;
  518 + int val{1};
519 519 app.add_option("--val", val);
520 520  
521 521 app.add_subcommand("sub");
... ... @@ -527,7 +527,7 @@ TEST_F(TApp, FallThroughRegular) {
527 527  
528 528 TEST_F(TApp, FallThroughShort) {
529 529 app.fallthrough();
530   - int val = 1;
  530 + int val{1};
531 531 app.add_option("-v", val);
532 532  
533 533 app.add_subcommand("sub");
... ... @@ -539,7 +539,7 @@ TEST_F(TApp, FallThroughShort) {
539 539  
540 540 TEST_F(TApp, FallThroughPositional) {
541 541 app.fallthrough();
542   - int val = 1;
  542 + int val{1};
543 543 app.add_option("val", val);
544 544  
545 545 app.add_subcommand("sub");
... ... @@ -551,7 +551,7 @@ TEST_F(TApp, FallThroughPositional) {
551 551  
552 552 TEST_F(TApp, FallThroughEquals) {
553 553 app.fallthrough();
554   - int val = 1;
  554 + int val{1};
555 555 app.add_option("--val", val);
556 556  
557 557 app.add_subcommand("sub");
... ... @@ -563,7 +563,7 @@ TEST_F(TApp, FallThroughEquals) {
563 563  
564 564 TEST_F(TApp, EvilParseFallthrough) {
565 565 app.fallthrough();
566   - int val1 = 0, val2 = 0;
  566 + int val1{0}, val2{0};
567 567 app.add_option("--val1", val1);
568 568  
569 569 auto sub = app.add_subcommand("sub");
... ... @@ -579,7 +579,7 @@ TEST_F(TApp, EvilParseFallthrough) {
579 579  
580 580 TEST_F(TApp, CallbackOrdering) {
581 581 app.fallthrough();
582   - int val = 1, sub_val = 0;
  582 + int val{1}, sub_val{0};
583 583 app.add_option("--val", val);
584 584  
585 585 auto sub = app.add_subcommand("sub");
... ... @@ -598,7 +598,7 @@ TEST_F(TApp, CallbackOrdering) {
598 598  
599 599 TEST_F(TApp, CallbackOrderingImmediate) {
600 600 app.fallthrough();
601   - int val = 1, sub_val = 0;
  601 + int val{1}, sub_val{0};
602 602 app.add_option("--val", val);
603 603  
604 604 auto sub = app.add_subcommand("sub")->immediate_callback();
... ... @@ -617,7 +617,7 @@ TEST_F(TApp, CallbackOrderingImmediate) {
617 617  
618 618 TEST_F(TApp, CallbackOrderingImmediateMain) {
619 619 app.fallthrough();
620   - int val = 0, sub_val = 0;
  620 + int val{0}, sub_val{0};
621 621  
622 622 auto sub = app.add_subcommand("sub");
623 623 sub->callback([&val, &sub_val]() {
... ... @@ -814,9 +814,9 @@ struct SubcommandProgram : public TApp {
814 814 CLI::App *start{nullptr};
815 815 CLI::App *stop{nullptr};
816 816  
817   - int dummy{};
  817 + int dummy{0};
818 818 std::string file{};
819   - int count{};
  819 + int count{0};
820 820  
821 821 SubcommandProgram(const SubcommandProgram &) = delete;
822 822 SubcommandProgram &operator=(const SubcommandProgram &) = delete;
... ... @@ -1360,7 +1360,7 @@ TEST_F(ManySubcommands, SubcommandNeedsOptions) {
1360 1360 }
1361 1361  
1362 1362 TEST_F(ManySubcommands, SubcommandNeedsOptionsCallbackOrdering) {
1363   - int count = 0;
  1363 + int count{0};
1364 1364 auto opt = app.add_flag("--subactive");
1365 1365 app.add_flag("--flag1");
1366 1366 sub1->needs(opt);
... ... @@ -1461,7 +1461,7 @@ TEST_F(ManySubcommands, SubcommandTriggeredOn) {
1461 1461 }
1462 1462  
1463 1463 TEST_F(TApp, UnnamedSub) {
1464   - double val;
  1464 + double val{0.0};
1465 1465 auto sub = app.add_subcommand("", "empty name");
1466 1466 auto opt = sub->add_option("-v,--value", val);
1467 1467 args = {"-v", "4.56"};
... ... @@ -1481,7 +1481,7 @@ TEST_F(TApp, UnnamedSub) {
1481 1481 }
1482 1482  
1483 1483 TEST_F(TApp, UnnamedSubMix) {
1484   - double val, val2, val3;
  1484 + double val{0.0}, val2{0.0}, val3{0.0};
1485 1485 app.add_option("-t", val2);
1486 1486 auto sub1 = app.add_subcommand("", "empty name");
1487 1487 sub1->add_option("-v,--value", val);
... ... @@ -1497,7 +1497,7 @@ TEST_F(TApp, UnnamedSubMix) {
1497 1497 }
1498 1498  
1499 1499 TEST_F(TApp, UnnamedSubMixExtras) {
1500   - double val, val2;
  1500 + double val{0.0}, val2{0.0};
1501 1501 app.add_option("-t", val2);
1502 1502 auto sub = app.add_subcommand("", "empty name");
1503 1503 sub->add_option("-v,--value", val);
... ... @@ -1511,7 +1511,7 @@ TEST_F(TApp, UnnamedSubMixExtras) {
1511 1511 }
1512 1512  
1513 1513 TEST_F(TApp, UnnamedSubNoExtras) {
1514   - double val, val2;
  1514 + double val{0.0}, val2{0.0};
1515 1515 app.add_option("-t", val2);
1516 1516 auto sub = app.add_subcommand();
1517 1517 sub->add_option("-v,--value", val);
... ... @@ -1524,7 +1524,7 @@ TEST_F(TApp, UnnamedSubNoExtras) {
1524 1524 }
1525 1525  
1526 1526 TEST_F(TApp, SubcommandAlias) {
1527   - double val;
  1527 + double val{0.0};
1528 1528 auto sub = app.add_subcommand("sub1");
1529 1529 sub->alias("sub2");
1530 1530 sub->alias("sub3");
... ... @@ -1552,7 +1552,7 @@ TEST_F(TApp, SubcommandAlias) {
1552 1552 }
1553 1553  
1554 1554 TEST_F(TApp, SubcommandAliasIgnoreCaseUnderscore) {
1555   - double val;
  1555 + double val{0.0};
1556 1556 auto sub = app.add_subcommand("sub1");
1557 1557 sub->alias("sub2");
1558 1558 sub->alias("sub3");
... ... @@ -1595,7 +1595,7 @@ TEST_F(TApp, SubcommandAliasIgnoreCaseUnderscore) {
1595 1595 }
1596 1596  
1597 1597 TEST_F(TApp, OptionGroupAlias) {
1598   - double val;
  1598 + double val{0.0};
1599 1599 auto sub = app.add_option_group("sub1");
1600 1600 sub->alias("sub2");
1601 1601 sub->alias("sub3");
... ... @@ -1694,7 +1694,7 @@ TEST_F(TApp, AliasErrorsInOptionGroup) {
1694 1694 }
1695 1695  
1696 1696 TEST(SharedSubTests, SharedSubcommand) {
1697   - double val, val2, val3, val4;
  1697 + double val{0.0}, val2{0.0}, val3{0.0}, val4{0.0};
1698 1698 CLI::App app1{"test program1"};
1699 1699  
1700 1700 app1.add_option("-t", val2);
... ... @@ -1724,7 +1724,7 @@ TEST(SharedSubTests, SharedSubcommand) {
1724 1724 }
1725 1725  
1726 1726 TEST(SharedSubTests, SharedSubIndependent) {
1727   - double val, val2, val4;
  1727 + double val{0.0}, val2{0.0}, val4{0.0};
1728 1728 CLI::App_p app1 = std::make_shared<CLI::App>("test program1");
1729 1729 app1->allow_extras();
1730 1730 app1->add_option("-t", val2);
... ... @@ -1752,7 +1752,7 @@ TEST(SharedSubTests, SharedSubIndependent) {
1752 1752 }
1753 1753  
1754 1754 TEST(SharedSubTests, SharedSubIndependentReuse) {
1755   - double val, val2, val4;
  1755 + double val{0.0}, val2{0.0}, val4{0.0};
1756 1756 CLI::App_p app1 = std::make_shared<CLI::App>("test program1");
1757 1757 app1->allow_extras();
1758 1758 app1->add_option("-t", val2);
... ...
tests/TransformTest.cpp
... ... @@ -14,7 +14,7 @@
14 14 #endif
15 15  
16 16 TEST_F(TApp, SimpleTransform) {
17   - int value;
  17 + int value{0};
18 18 auto opt = app.add_option("-s", value)->transform(CLI::Transformer({{"one", std::string("1")}}));
19 19 args = {"-s", "one"};
20 20 run();
... ... @@ -24,7 +24,7 @@ TEST_F(TApp, SimpleTransform) {
24 24 }
25 25  
26 26 TEST_F(TApp, SimpleTransformInitList) {
27   - int value;
  27 + int value{0};
28 28 auto opt = app.add_option("-s", value)->transform(CLI::Transformer({{"one", "1"}}));
29 29 args = {"-s", "one"};
30 30 run();
... ... @@ -34,7 +34,7 @@ TEST_F(TApp, SimpleTransformInitList) {
34 34 }
35 35  
36 36 TEST_F(TApp, SimpleNumericalTransform) {
37   - int value;
  37 + int value{0};
38 38 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(CLI::TransformPairs<int>{{"one", 1}}));
39 39 args = {"-s", "one"};
40 40 run();
... ... @@ -45,7 +45,7 @@ TEST_F(TApp, SimpleNumericalTransform) {
45 45  
46 46 TEST_F(TApp, EnumTransform) {
47 47 enum class test : std::int16_t { val1 = 3, val2 = 4, val3 = 17 };
48   - test value;
  48 + test value{test::val2};
49 49 auto opt = app.add_option("-s", value)
50 50 ->transform(CLI::Transformer(
51 51 CLI::TransformPairs<test>{{"val1", test::val1}, {"val2", test::val2}, {"val3", test::val3}}));
... ... @@ -74,7 +74,7 @@ TEST_F(TApp, EnumTransform) {
74 74  
75 75 TEST_F(TApp, EnumCheckedTransform) {
76 76 enum class test : std::int16_t { val1 = 3, val2 = 4, val3 = 17 };
77   - test value;
  77 + test value{test::val1};
78 78 auto opt = app.add_option("-s", value)
79 79 ->transform(CLI::CheckedTransformer(
80 80 CLI::TransformPairs<test>{{"val1", test::val1}, {"val2", test::val2}, {"val3", test::val3}}));
... ... @@ -141,7 +141,7 @@ TEST_F(TApp, EnumCheckedDefaultTransformCallback) {
141 141 }
142 142  
143 143 TEST_F(TApp, SimpleTransformFn) {
144   - int value;
  144 + int value{0};
145 145 auto opt = app.add_option("-s", value)->transform(CLI::Transformer({{"one", "1"}}, CLI::ignore_case));
146 146 args = {"-s", "ONE"};
147 147 run();
... ... @@ -164,7 +164,7 @@ TEST_F(TApp, StringViewTransformFn) {
164 164 #endif
165 165  
166 166 TEST_F(TApp, SimpleNumericalTransformFn) {
167   - int value;
  167 + int value{0};
168 168 auto opt =
169 169 app.add_option("-s", value)
170 170 ->transform(CLI::Transformer(std::vector<std::pair<std::string, int>>{{"one", 1}}, CLI::ignore_case));
... ... @@ -177,7 +177,7 @@ TEST_F(TApp, SimpleNumericalTransformFn) {
177 177  
178 178 TEST_F(TApp, SimpleNumericalTransformFnVector) {
179 179 std::vector<std::pair<std::string, int>> conversions{{"one", 1}, {"two", 2}};
180   - int value;
  180 + int value{0};
181 181 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(conversions, CLI::ignore_case));
182 182 args = {"-s", "ONe"};
183 183 run();
... ... @@ -191,7 +191,7 @@ TEST_F(TApp, SimpleNumericalTransformFnArray) {
191 191 conversions[0] = std::make_pair(std::string("one"), 1);
192 192 conversions[1] = std::make_pair(std::string("two"), 2);
193 193  
194   - int value;
  194 + int value{0};
195 195 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(conversions, CLI::ignore_case));
196 196 args = {"-s", "ONe"};
197 197 run();
... ... @@ -207,7 +207,7 @@ TEST_F(TApp, SimpleNumericalTransformFnconstexprArray) {
207 207 constexpr std::pair<const char *, int> p2{"two", 2};
208 208 constexpr std::array<std::pair<const char *, int>, 2> conversions_c{{p1, p2}};
209 209  
210   - int value;
  210 + int value{0};
211 211 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(&conversions_c, CLI::ignore_case));
212 212 args = {"-s", "ONe"};
213 213 run();
... ... @@ -225,7 +225,7 @@ TEST_F(TApp, SimpleNumericalTransformFnconstexprArray) {
225 225  
226 226 TEST_F(TApp, EnumTransformFn) {
227 227 enum class test : std::int16_t { val1 = 3, val2 = 4, val3 = 17 };
228   - test value;
  228 + test value{test::val2};
229 229 auto opt = app.add_option("-s", value)
230 230 ->transform(CLI::Transformer(
231 231 CLI::TransformPairs<test>{{"val1", test::val1}, {"val2", test::val2}, {"val3", test::val3}},
... ... @@ -252,7 +252,7 @@ TEST_F(TApp, EnumTransformFn) {
252 252 TEST_F(TApp, EnumTransformFnMap) {
253 253 enum class test : std::int16_t { val1 = 3, val2 = 4, val3 = 17 };
254 254 std::map<std::string, test> map{{"val1", test::val1}, {"val2", test::val2}, {"val3", test::val3}};
255   - test value;
  255 + test value{test::val3};
256 256 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(map, CLI::ignore_case, CLI::ignore_underscore));
257 257 args = {"-s", "val_1"};
258 258 run();
... ... @@ -275,7 +275,7 @@ TEST_F(TApp, EnumTransformFnMap) {
275 275 TEST_F(TApp, EnumTransformFnPtrMap) {
276 276 enum class test : std::int16_t { val1 = 3, val2 = 4, val3 = 17, val4 = 37 };
277 277 std::map<std::string, test> map{{"val1", test::val1}, {"val2", test::val2}, {"val3", test::val3}};
278   - test value;
  278 + test value{test::val2};
279 279 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(&map, CLI::ignore_case, CLI::ignore_underscore));
280 280 args = {"-s", "val_1"};
281 281 run();
... ... @@ -307,7 +307,7 @@ TEST_F(TApp, EnumTransformFnSharedPtrMap) {
307 307 mp["val2"] = test::val2;
308 308 mp["val3"] = test::val3;
309 309  
310   - test value;
  310 + test value{test::val2};
311 311 auto opt = app.add_option("-s", value)->transform(CLI::Transformer(map, CLI::ignore_case, CLI::ignore_underscore));
312 312 args = {"-s", "val_1"};
313 313 run();
... ... @@ -565,7 +565,7 @@ TEST_F(TApp, NumberWithUnitCorrecltySplitNumber) {
565 565  
566 566 TEST_F(TApp, NumberWithUnitFloatTest) {
567 567 std::map<std::string, double> mapping{{"a", 10}, {"b", 100}, {"cc", 1000}};
568   - double value = 0;
  568 + double value{0.0};
569 569 app.add_option("-n", value)->transform(CLI::AsNumberWithUnit(mapping));
570 570  
571 571 args = {"-n", "42"};
... ... @@ -588,7 +588,7 @@ TEST_F(TApp, NumberWithUnitFloatTest) {
588 588 TEST_F(TApp, NumberWithUnitCaseSensitive) {
589 589 std::map<std::string, int> mapping{{"a", 10}, {"A", 100}};
590 590  
591   - int value = 0;
  591 + int value{0};
592 592 app.add_option("-n", value)->transform(CLI::AsNumberWithUnit(mapping, CLI::AsNumberWithUnit::CASE_SENSITIVE));
593 593  
594 594 args = {"-n", "42a"};
... ... @@ -603,7 +603,7 @@ TEST_F(TApp, NumberWithUnitCaseSensitive) {
603 603 TEST_F(TApp, NumberWithUnitCaseInsensitive) {
604 604 std::map<std::string, int> mapping{{"a", 10}, {"B", 100}};
605 605  
606   - int value = 0;
  606 + int value{0};
607 607 app.add_option("-n", value)->transform(CLI::AsNumberWithUnit(mapping, CLI::AsNumberWithUnit::CASE_INSENSITIVE));
608 608  
609 609 args = {"-n", "42a"};
... ... @@ -626,7 +626,7 @@ TEST_F(TApp, NumberWithUnitCaseInsensitive) {
626 626 TEST_F(TApp, NumberWithUnitMandatoryUnit) {
627 627 std::map<std::string, int> mapping{{"a", 10}, {"A", 100}};
628 628  
629   - int value;
  629 + int value{0};
630 630 app.add_option("-n", value)
631 631 ->transform(CLI::AsNumberWithUnit(mapping,
632 632 CLI::AsNumberWithUnit::Options(CLI::AsNumberWithUnit::UNIT_REQUIRED |
... ... @@ -647,7 +647,7 @@ TEST_F(TApp, NumberWithUnitMandatoryUnit) {
647 647 TEST_F(TApp, NumberWithUnitMandatoryUnit2) {
648 648 std::map<std::string, int> mapping{{"a", 10}, {"B", 100}};
649 649  
650   - int value;
  650 + int value{0};
651 651 app.add_option("-n", value)
652 652 ->transform(CLI::AsNumberWithUnit(mapping,
653 653 CLI::AsNumberWithUnit::Options(CLI::AsNumberWithUnit::UNIT_REQUIRED |
... ... @@ -677,7 +677,7 @@ TEST_F(TApp, NumberWithUnitBadMapping) {
677 677 TEST_F(TApp, NumberWithUnitBadInput) {
678 678 std::map<std::string, int> mapping{{"a", 10}, {"b", 100}};
679 679  
680   - int value;
  680 + int value{0};
681 681 app.add_option("-n", value)->transform(CLI::AsNumberWithUnit(mapping));
682 682  
683 683 args = {"-n", "13 a b"};
... ... @@ -723,7 +723,7 @@ TEST_F(TApp, NumberWithUnitIntOverflow) {
723 723 TEST_F(TApp, NumberWithUnitFloatOverflow) {
724 724 std::map<std::string, float> mapping{{"a", 2.f}, {"b", 1.f}, {"c", 0.f}};
725 725  
726   - float value;
  726 + float value{0.0F};
727 727 app.add_option("-n", value)->transform(CLI::AsNumberWithUnit(mapping));
728 728  
729 729 args = {"-n", "3e+38 a"};
... ... @@ -739,7 +739,7 @@ TEST_F(TApp, NumberWithUnitFloatOverflow) {
739 739 }
740 740  
741 741 TEST_F(TApp, AsSizeValue1000_1024) {
742   - std::uint64_t value;
  742 + std::uint64_t value{0};
743 743 app.add_option("-s", value)->transform(CLI::AsSizeValue(true));
744 744  
745 745 args = {"-s", "10240"};
... ... @@ -750,8 +750,8 @@ TEST_F(TApp, AsSizeValue1000_1024) {
750 750 run();
751 751 EXPECT_EQ(value, 1u);
752 752  
753   - std::uint64_t k_value = 1000u;
754   - std::uint64_t ki_value = 1024u;
  753 + std::uint64_t k_value{1000u};
  754 + std::uint64_t ki_value{1024u};
755 755 args = {"-s", "1k"};
756 756 run();
757 757 EXPECT_EQ(value, k_value);
... ... @@ -845,7 +845,7 @@ TEST_F(TApp, AsSizeValue1000_1024) {
845 845 }
846 846  
847 847 TEST_F(TApp, AsSizeValue1024) {
848   - std::uint64_t value;
  848 + std::uint64_t value{0};
849 849 app.add_option("-s", value)->transform(CLI::AsSizeValue(false));
850 850  
851 851 args = {"-s", "10240"};
... ... @@ -856,7 +856,7 @@ TEST_F(TApp, AsSizeValue1024) {
856 856 run();
857 857 EXPECT_EQ(value, 1u);
858 858  
859   - std::uint64_t ki_value = 1024u;
  859 + std::uint64_t ki_value{1024u};
860 860 args = {"-s", "1k"};
861 861 run();
862 862 EXPECT_EQ(value, ki_value);
... ...
tests/TrueFalseTest.cpp
... ... @@ -4,7 +4,7 @@
4 4 struct TApp_TBO : public TApp, public ::testing::WithParamInterface<const char *> {};
5 5  
6 6 TEST_P(TApp_TBO, TrueBoolOption) {
7   - bool value = false; // Not used, but set just in case
  7 + bool value{false}; // Not used, but set just in case
8 8 app.add_option("-b,--bool", value);
9 9 args = {"--bool", GetParam()};
10 10 run();
... ... @@ -19,7 +19,7 @@ INSTANTIATE_TEST_CASE_P(TrueBoolOptions, TApp_TBO, ::testing::Values(&quot;true&quot;, &quot;on
19 19 struct TApp_FBO : public TApp, public ::testing::WithParamInterface<const char *> {};
20 20  
21 21 TEST_P(TApp_FBO, FalseBoolOptions) {
22   - bool value = true; // Not used, but set just in case
  22 + bool value{true}; // Not used, but set just in case
23 23 app.add_option("-b,--bool", value);
24 24 args = {"--bool", GetParam()};
25 25 run();
... ...