1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

Adding tests for old behavior

This commit is contained in:
Henry Fredrick Schreiner 2018-04-09 12:26:04 +02:00 committed by Henry Schreiner
parent 232c792bae
commit 0303929552

View File

@ -407,6 +407,33 @@ TEST_F(TApp, PrefixProgram) {
EXPECT_EQ(app.remaining(), std::vector<std::string>({"other", "--simple", "--mine"}));
}
TEST_F(TApp, PrefixNoSeparation) {
app.prefix_command();
std::vector<int> vals;
app.add_option("--vals", vals);
args = {"--vals", "1", "2", "3", "other"};
EXPECT_THROW(run(), CLI::ConversionError);
}
TEST_F(TApp, PrefixSeparation) {
app.prefix_command();
std::vector<int> vals;
app.add_option("--vals", vals);
args = {"--vals", "1", "2", "3", "--", "other"};
run();
EXPECT_EQ(app.remaining(), std::vector<std::string>({"--", "other"}));
EXPECT_EQ(vals, std::vector<int>({1, 2, 3}));
}
TEST_F(TApp, PrefixSubcom) {
auto subc = app.add_subcommand("subc");
subc->prefix_command();