Changeset 1868


Ignore:
Timestamp:
Mar 17, 2009, 9:08:21 PM (12 years ago)
Author:
Peter
Message:

refs #508. adding a test for the bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.5-stable/test/commandline_test.cc

    r1634 r1868  
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3637bool test_switch(yat::test::Suite& error);
    3738bool test_arg(yat::test::Suite& error);
     39void test_exception_msg(yat::test::Suite& error);
    3840bool test_file(yat::test::Suite& error);
    3941bool test_failures(yat::test::Suite& error);
     
    5658    suite.add(test_option_name_clash(suite));
    5759    suite.add(test_free_arg(suite));
     60    test_exception_msg(suite);
    5861  }
    5962  catch (std::runtime_error& e) {
     
    8689}
    8790
     91
     92void test_exception_msg(yat::test::Suite& suite)
     93{
     94  // test for ticket 508
     95  using namespace theplu::yat::utility;
     96  CommandLine cmd;
     97  OptionHelp help(cmd, "h,help", "");
     98  OptionFile indata(cmd, "i,in", "input file", true, true,"r");
     99  OptionSwitch cmd_memory(cmd, "m", "transpose in a memory cheap manner");
     100  OptionArg<size_t> cmd_n(cmd, "n", "number of rows to print in each iteration");
     101  OptionSwitch cmd_numeric(cmd, "numeric",
     102                                         "input is a numeric matrix");
     103  OptionFile outdata(cmd, "o,out", "output file",true, false,"w");
     104  OptionSwitch verbose(cmd, "v,verbose", "display progress");
     105  int ac = 2;
     106  char* av[] = { "test_prog", "--haha" };
     107  try {
     108    cmd.parse(ac,av);
     109  }
     110  catch (std::runtime_error& e) {
     111    std::string msg(e.what());
     112    if (msg.size()<15) {
     113      suite.xadd(false);
     114      suite.err() << "Error: short exception message\n"
     115                  << "  exception message is: `" << msg
     116                  << "' that is " << msg.size() << " characters long.\n"
     117                  << "  expected at least 15 characters\n";
     118    }
     119  }
     120}
     121
     122
    88123bool test_switch(yat::test::Suite& suite)
    89124{
Note: See TracChangeset for help on using the changeset viewer.