Ignore:
Timestamp:
Aug 21, 2008, 12:26:31 AM (15 years ago)
Author:
Peter
Message:

fixes #414

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/commandline_test.cc

    r1275 r1426  
    4040bool test_file(yat::test::Suite& error);
    4141bool test_failures(yat::test::Suite& error);
     42bool test_option_name_clash(yat::test::Suite& suite);
    4243
    4344int main(int argc, char* argv[])
     
    5455    suite.add(test_file(suite));
    5556    suite.add(test_failures(suite));
     57    suite.add(test_option_name_clash(suite));
    5658  }
    5759  catch (std::runtime_error& e) {
    58     suite.err() << "exception thrown\n" << e.what() << std::endl;
     60    suite.err() << "Error: unexpected exception thrown\n" << e.what()
     61                << std::endl;
     62    suite.add(false);
    5963  }
    6064
     
    360364  suite.err() << "Testing OptionFile... ";
    361365  {
    362     int ac = 2;
    363     char* av[] = { "test_prog", "--clones", "commandline_test.cc"
     366    int ac = 7;
     367    char* av[] = { "test_prog", "--clones", "commandline_test.cc",
    364368                   "--data", "commandline_test.cc", "-o",
    365369                   "commandline_test.cc"};
     
    370374}
    371375
    372 
    373 
    374 
    375 
     376bool test_option_name_clash(yat::test::Suite& suite)
     377{
     378  bool ok=true;
     379  suite.err() << "Testing long option name clash ...";
     380  try {
     381    CommandLine cmd;
     382    OptionSwitch op1(cmd, "opt", "bla bla");
     383    OptionSwitch op2(cmd, "o,opt", "other bla");
     384    ok=false;
     385    suite.err() << "failed\n";
     386  }
     387  catch (std::runtime_error& e) {
     388    suite.err() << "ok\n";
     389  }
     390  suite.err() << "Testing short option name clash ...";
     391  try {
     392    CommandLine cmd;
     393    OptionSwitch op1(cmd, "o", "bla bla");
     394    OptionSwitch op2(cmd, "o,opt", "other bla");
     395    ok=false;
     396    suite.err() << "failed\n";
     397  }
     398  catch (std::runtime_error& e) {
     399    suite.err() << "ok\n";
     400  }
     401
     402  return ok;
     403}
     404
     405
     406
     407
Note: See TracChangeset for help on using the changeset viewer.