Commit 0973f348d2f652f04f26e90fe7a2657ec60c476f
1 parent
3da48079
Adding new tests for red lines
Showing
1 changed file
with
40 additions
and
0 deletions
tests/AppTest.cpp
| ... | ... | @@ -892,3 +892,43 @@ TEST_F(TApp, CheckSubcomFail) { |
| 892 | 892 | |
| 893 | 893 | EXPECT_THROW(CLI::detail::AppFriend::parse_subcommand(&app, args), CLI::HorribleError); |
| 894 | 894 | } |
| 895 | + | |
| 896 | +// Added to test defaults on dual method | |
| 897 | +TEST_F(TApp, OptionWithDefaults) { | |
| 898 | + int someint=2; | |
| 899 | + app.add_option("-a", someint, "", true); | |
| 900 | + | |
| 901 | + args = {"-a1", "-a2"}; | |
| 902 | + | |
| 903 | + EXPECT_THROW(run(), CLI::ConversionError); | |
| 904 | +} | |
| 905 | + | |
| 906 | +// Added to test defaults on dual method | |
| 907 | +TEST_F(TApp, SetWithDefaults) { | |
| 908 | + int someint=2; | |
| 909 | + app.add_set("-a", someint, {1,2,3,4}, "", true); | |
| 910 | + | |
| 911 | + args = {"-a1", "-a2"}; | |
| 912 | + | |
| 913 | + EXPECT_THROW(run(), CLI::ConversionError); | |
| 914 | +} | |
| 915 | + | |
| 916 | +// Added to test defaults on dual method | |
| 917 | +TEST_F(TApp, SetWithDefaultsConversion) { | |
| 918 | + int someint=2; | |
| 919 | + app.add_set("-a", someint, {1,2,3,4}, "", true); | |
| 920 | + | |
| 921 | + args = {"-a", "hi"}; | |
| 922 | + | |
| 923 | + EXPECT_THROW(run(), CLI::ConversionError); | |
| 924 | +} | |
| 925 | + | |
| 926 | +// Added to test defaults on dual method | |
| 927 | +TEST_F(TApp, SetWithDefaultsIC) { | |
| 928 | + std::string someint="ho"; | |
| 929 | + app.add_set_ignore_case("-a", someint, {"Hi", "Ho"}, "", true); | |
| 930 | + | |
| 931 | + args = {"-aHi", "-aHo"}; | |
| 932 | + | |
| 933 | + EXPECT_THROW(run(), CLI::ConversionError); | |
| 934 | +} | ... | ... |