Changeset 1744


Ignore:
Timestamp:
Jun 13, 2011 6:53:10 AM (8 years ago)
Author:
stefan
Message:

handle exceptions like other unittest failures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/test/osiUnitTest.cpp

    r1743 r1744  
    1 // $Id$
    21// Copyright (C) 2000, International Business Machines
    32// Corporation and others.  All Rights Reserved.
    43// This code is licensed under the terms of the Eclipse Public License (EPL).
     4// $Id$
    55
    66#include "CoinPragma.hpp"
     
    2727int main (int argc, const char *argv[])
    2828{
    29   bool exception = false;
    3029/*
    3130  Start off with various bits of initialisation that don't really belong
    3231  anywhere else.
    33 */
     32 */
    3433  outcomes.clear();
    3534/*
     
    3736  output a bit more comprehensible. It still suffers from interleave of cout
    3837  (stdout) and cerr (stderr), but -nobuf deals with that.
    39 */
     38 */
    4039  std::ios::sync_with_stdio() ;
    4140/*
    4241  Suppress an popup window that Windows shows in response to a crash. See
    4342  note at head of file.
    44 */
     43 */
    4544  WindowsErrorPopupBlocker();
    4645
    4746/*
    4847  Process command line parameters.
    49 */
     48 */
    5049  std::map<std::string,std::string> parms;
    5150  if (processParameters(argc,argv,parms) == false)
    52   { return (1) ; }
     51    return 1;
    5352
    5453  std::string mpsDir = parms["-mpsDir"] ;
    5554  std::string netlibDir = parms["-netlibDir"] ;
    5655
    57   try {
    58     /*
    59       Test Osi{Row,Col}Cut routines.
    60     */
    61     {
    62       OsiClpSolverInterface clpSi;
    63       testingMessage( "Testing OsiRowCut with OsiClpSolverInterface\n" );
    64       OsiRowCutUnitTest(&clpSi,mpsDir);
    65     }
    66     {
    67       OsiClpSolverInterface clpSi;
    68       testingMessage( "Testing OsiColCut with OsiClpSolverInterface\n" );
    69       OsiColCutUnitTest(&clpSi,mpsDir);
    70     }
    71     {
    72       OsiClpSolverInterface clpSi;
    73       testingMessage( "Testing OsiRowCutDebugger with OsiClpSolverInterface\n" );
    74       OsiRowCutDebuggerUnitTest(&clpSi,mpsDir);
    75     }
    76 
    77     /*
    78       Run the OsiClp class test. This will also call OsiSolverInterfaceCommonUnitTest.
    79     */
    80     testingMessage( "Testing OsiClpSolverInterface\n" );
    81     OsiClpSolverInterfaceUnitTest(mpsDir,netlibDir);
    82 
    83     /*
    84       We have run the specialised unit test.
    85       Check now to see if we need to run through the Netlib problems.
    86     */
    87     if (parms.find("-testOsiSolverInterface") != parms.end())
    88     {
    89       // Create vector of solver interfaces
    90       std::vector<OsiSolverInterface*> vecSi(1, new OsiClpSolverInterface);
    91 
    92       testingMessage( "Testing OsiSolverInterface on Netlib problems.\n" );
    93       OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir);
    94 
    95       delete vecSi[0];
    96     }
    97     else {
    98       testingMessage( "***Skipped Testing of OsiClpSolverInterface on Netlib problems***\n" );
    99       testingMessage( "***use -testOsiSolverInterface to run them.***\n" );
    100     }
    101   } catch (CoinError& error) {
    102     std::cout.flush();
    103     std::cerr << "Caught CoinError exception: ";
    104     error.print(true);
    105     exception = true;
     56  /*
     57    Test Osi{Row,Col}Cut routines.
     58   */
     59  {
     60    OsiClpSolverInterface clpSi;
     61    testingMessage( "Testing OsiRowCut with OsiClpSolverInterface\n" );
     62    OSIUNITTEST_CATCH_ERROR(OsiRowCutUnitTest(&clpSi,mpsDir), {}, clpSi, "rowcut unittest");
     63  }
     64  {
     65    OsiClpSolverInterface clpSi;
     66    testingMessage( "Testing OsiColCut with OsiClpSolverInterface\n" );
     67    OSIUNITTEST_CATCH_ERROR(OsiColCutUnitTest(&clpSi,mpsDir), {}, clpSi, "colcut unittest");
     68  }
     69  {
     70    OsiClpSolverInterface clpSi;
     71    testingMessage( "Testing OsiRowCutDebugger with OsiClpSolverInterface\n" );
     72    OSIUNITTEST_CATCH_ERROR(OsiRowCutDebuggerUnitTest(&clpSi,mpsDir), {}, clpSi, "rowcut debugger unittest");
    10673  }
    10774
    10875  /*
     76    Run the OsiClp class test. This will also call OsiSolverInterfaceCommonUnitTest.
     77   */
     78  testingMessage( "Testing OsiClpSolverInterface\n" );
     79  OSIUNITTEST_CATCH_ERROR(OsiClpSolverInterfaceUnitTest(mpsDir,netlibDir), {}, "clp", "osiclp unittest");
     80
     81  /*
     82    We have run the specialised unit test.
     83    Check now to see if we need to run through the Netlib problems.
     84   */
     85  if (parms.find("-testOsiSolverInterface") != parms.end())
     86  {
     87    // Create vector of solver interfaces
     88    std::vector<OsiSolverInterface*> vecSi(1, new OsiClpSolverInterface);
     89
     90    testingMessage( "Testing OsiSolverInterface on Netlib problems.\n" );
     91    OSIUNITTEST_CATCH_ERROR(OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir), {}, "clp", "netlib unittest");
     92
     93    delete vecSi[0];
     94  }
     95  else
     96    testingMessage( "***Skipped Testing of OsiClpSolverInterface on Netlib problems, use -testOsiSolverInterface to run them.***\n" );
     97
     98  /*
    10999    We're done. Report on the results.
    110   */
     100   */
    111101  std::cout.flush();
    112102  outcomes.print();
     
    118108  if (nerrors > nerrors_expected)
    119109    std::cerr << "Tests completed with " << nerrors - nerrors_expected << " unexpected errors." << std::endl ;
    120   else if( exception )
    121     std::cerr << "Tests completed with exception\n";
    122110  else
    123111    std::cerr << "All tests completed successfully\n";
    124112
    125   return (nerrors - nerrors_expected) + (exception ? 1 : 0);
     113  return nerrors - nerrors_expected;
    126114}
Note: See TracChangeset for help on using the changeset viewer.