Commit 89c57961f4e5cb3caa6bcab287e0a5feb073ba21

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent 59b6de25

Adding more tests

Showing 1 changed file with 18 additions and 4 deletions
tests/SubcommandTest.cpp
... ... @@ -299,10 +299,10 @@ TEST_F(TApp, SubComExtras) {
299 299  
300 300 app.reset();
301 301  
302   - // args = {"sub", "extra"};
303   - // run();
304   - // EXPECT_EQ(app.remaining(), std::vector<std::string>());
305   - // EXPECT_EQ(sub->remaining(), std::vector<std::string>({"extra"}));
  302 + args = {"sub", "extra1", "extra2"};
  303 + run();
  304 + EXPECT_EQ(app.remaining(), std::vector<std::string>());
  305 + EXPECT_EQ(sub->remaining(), std::vector<std::string>({"extra1", "extra2"}));
306 306 }
307 307  
308 308 TEST_F(TApp, Required1SubCom) {
... ... @@ -342,6 +342,20 @@ TEST_F(TApp, PrefixProgram) {
342 342 EXPECT_EQ(app.remaining(), std::vector<std::string>({"other", "--simple", "--mine"}));
343 343 }
344 344  
  345 +TEST_F(TApp, PrefixSubcom) {
  346 + auto subc = app.add_subcommand("subc");
  347 + subc->prefix_command();
  348 +
  349 + app.add_flag("--simple");
  350 +
  351 + args = {"--simple", "subc", "other", "--simple", "--mine"};
  352 + run();
  353 +
  354 + EXPECT_EQ(app.remaining_size(), (size_t) 0);
  355 + EXPECT_EQ(app.remaining_size(true), (size_t) 3);
  356 + EXPECT_EQ(subc->remaining(), std::vector<std::string>({"other", "--simple", "--mine"}));
  357 +}
  358 +
345 359 struct SubcommandProgram : public TApp {
346 360  
347 361 CLI::App *start;
... ...