Changeset 1666 for trunk/Cbc/test


Ignore:
Timestamp:
Jun 13, 2011 9:45:24 AM (8 years ago)
Author:
stefan
Message:

use new osi unittest macros and functions in osicbc test

Location:
trunk/Cbc/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/test/OsiCbcSolverInterfaceTest.cpp

    r1574 r1666  
    44// This code is licensed under the terms of the Eclipse Public License (EPL).
    55
    6 #if defined(_MSC_VER)
    7 // Turn off compiler warning about long names
    8 #  pragma warning(disable:4786)
    9 #endif
    10 
    11 #ifdef NDEBUG
    12 #undef NDEBUG
    13 #endif
    14 
    15 #include "OsiConfig.h"
    16 
    17 #include <cassert>
     6#include "CoinPragma.hpp"
     7
     8//#include <cassert>
    189//#include <cstdlib>
    1910//#include <cstdio>
     
    2415#include "OsiRowCut.hpp"
    2516#include "OsiColCut.hpp"
     17#include "OsiUnitTests.hpp"
    2618#include "CoinMessage.hpp"
    2719#include "CoinModel.hpp"
    28 #ifdef COIN_HAS_OSL
    29 #include "OsiOslSolverInterface.hpp"
    30 #endif
    3120
    3221//#############################################################################
     
    7059OsiCbcSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir)
    7160{
    72  
    73  
    7461  {   
    7562    CoinRelFltEq eq;
     
    8067    {
    8168      OsiCbcSolverInterface im;   
    82      
    83       assert( im.getNumCols() == 0 );
    84      
    85       assert( im.getModelPtr()!=NULL );
     69      OSIUNITTEST_ASSERT_ERROR(im.getNumCols() == 0, {}, "cbc", "default constructor");
     70      OSIUNITTEST_ASSERT_ERROR(im.getModelPtr() != NULL, {}, "cbc", "default constructor");
    8671    }
    8772   
     
    9378       
    9479        OsiCbcSolverInterface imC1(im);
    95         assert( imC1.getModelPtr()!=im.getModelPtr() );
    96         assert( imC1.getNumCols() == im.getNumCols() );
    97         assert( imC1.getNumRows() == im.getNumRows() );   
     80        OSIUNITTEST_ASSERT_ERROR(imC1.getModelPtr() != im.getModelPtr(), {}, "cbc", "copy constructor");
     81        OSIUNITTEST_ASSERT_ERROR(imC1.getNumCols()  == im.getNumCols(),  {}, "cbc", "copy constructor");
     82        OSIUNITTEST_ASSERT_ERROR(imC1.getNumRows()  == im.getNumRows(),  {}, "cbc", "copy constructor");
    9883       
    9984        OsiCbcSolverInterface imC2(im);
    100         assert( imC2.getModelPtr()!=im.getModelPtr() );
    101         assert( imC2.getNumCols() == im.getNumCols() );
    102         assert( imC2.getNumRows() == im.getNumRows() ); 
     85        OSIUNITTEST_ASSERT_ERROR(imC2.getModelPtr() != im.getModelPtr(), {}, "cbc", "copy constructor");
     86        OSIUNITTEST_ASSERT_ERROR(imC2.getNumCols()  == im.getNumCols(),  {}, "cbc", "copy constructor");
     87        OSIUNITTEST_ASSERT_ERROR(imC2.getNumRows()  == im.getNumRows(),  {}, "cbc", "copy constructor");
     88
     89        OSIUNITTEST_ASSERT_ERROR(imC1.getModelPtr() != imC2.getModelPtr(), {}, "cbc", "copy constructor");
    10390       
    104         assert( imC2.getModelPtr()!=imC1.getModelPtr() );
    105        
    106         lhs=imC2;
    107       }
     91        lhs = imC2;
     92      }
     93
    10894      // Test that lhs has correct values even though rhs has gone out of scope
    109      
    110       assert( lhs.getModelPtr() != m.getModelPtr() );
    111       assert( lhs.getNumCols() == m.getNumCols() );
    112       assert( lhs.getNumRows() == m.getNumRows() );     
    113     }
     95      OSIUNITTEST_ASSERT_ERROR(lhs.getModelPtr() != m.getModelPtr(), {}, "cbc", "assignment operator");
     96      OSIUNITTEST_ASSERT_ERROR(lhs.getNumCols()  == m.getNumCols(),  {}, "cbc", "copy constructor");
     97      OSIUNITTEST_ASSERT_ERROR(lhs.getNumRows()  == m.getNumRows(),  {}, "cbc", "copy constructor");
     98    }
     99
    114100    // Test clone
    115101    {
    116       OsiCbcSolverInterface oslSi(m);
    117       OsiSolverInterface * siPtr = &oslSi;
     102      OsiCbcSolverInterface cbcSi(m);
     103      OsiSolverInterface * siPtr = &cbcSi;
    118104      OsiSolverInterface * siClone = siPtr->clone();
    119       OsiCbcSolverInterface * oslClone = dynamic_cast<OsiCbcSolverInterface*>(siClone);
    120       assert( oslClone != NULL );
    121       assert( oslClone->getModelPtr() != oslSi.getModelPtr() );
    122       assert( oslClone->getNumRows() == oslSi.getNumRows() );
    123       assert( oslClone->getNumCols() == m.getNumCols() );
     105      OsiCbcSolverInterface * cbcClone = dynamic_cast<OsiCbcSolverInterface*>(siClone);
     106
     107      OSIUNITTEST_ASSERT_ERROR(cbcClone != NULL, {}, "cbc", "clone");
     108      OSIUNITTEST_ASSERT_ERROR(cbcClone->getModelPtr() != cbcSi.getModelPtr(), {}, "cbc", "clone");
     109      OSIUNITTEST_ASSERT_ERROR(cbcClone->getNumRows() == cbcSi.getNumRows(),   {}, "cbc", "clone");
     110      OSIUNITTEST_ASSERT_ERROR(cbcClone->getNumCols() == m.getNumCols(),       {}, "cbc", "clone");
    124111     
    125112      delete siClone;
     
    129116    {
    130117      OsiCbcSolverInterface si;
    131       assert( eq(si.getInfinity(),OsiCbcInfinity));
     118      OSIUNITTEST_ASSERT_ERROR(si.getInfinity() == OsiCbcInfinity, {}, "cbc", "infinity");
    132119    }     
    133120   
    134     // Test setting solution
     121    // Test some catches
     122    if (!OsiCbcHasNDEBUG())
    135123    {
    136       OsiCbcSolverInterface m1(m);
    137       int i;
    138 
    139       double * cs = new double[m1.getNumCols()];
    140       for ( i = 0;  i < m1.getNumCols();  i++ )
    141         cs[i] = i + .5;
    142       m1.setColSolution(cs);
    143       for ( i = 0;  i < m1.getNumCols();  i++ )
    144         assert(m1.getColSolution()[i] == i + .5);
    145      
    146       double * rs = new double[m1.getNumRows()];
    147       for ( i = 0;  i < m1.getNumRows();  i++ )
    148         rs[i] = i - .5;
    149       m1.setRowPrice(rs);
    150       for ( i = 0;  i < m1.getNumRows();  i++ )
    151         assert(m1.getRowPrice()[i] == i - .5);
    152 
    153       delete [] cs;
    154       delete [] rs;
    155     }
    156    
    157    
    158     // Test fraction Indices
    159     {
    160       OsiCbcSolverInterface fim;
    161       std::string fn = mpsDir+"exmip1";
    162       fim.readMps(fn.c_str(),"mps");
    163       // exmip1.mps has 2 integer variables with index 2 & 3
    164       assert(  fim.isContinuous(0) );
    165       assert(  fim.isContinuous(1) );
    166       assert( !fim.isContinuous(2) );
    167       assert( !fim.isContinuous(3) );
    168       assert(  fim.isContinuous(4) );
    169      
    170       assert( !fim.isInteger(0) );
    171       assert( !fim.isInteger(1) );
    172       assert(  fim.isInteger(2) );
    173       assert(  fim.isInteger(3) );
    174       assert( !fim.isInteger(4) );
    175      
    176       assert( !fim.isBinary(0) );
    177       assert( !fim.isBinary(1) );
    178       assert(  fim.isBinary(2) );
    179       assert(  fim.isBinary(3) );
    180       assert( !fim.isBinary(4) );
    181      
    182       assert( !fim.isIntegerNonBinary(0) );
    183       assert( !fim.isIntegerNonBinary(1) );
    184       assert( !fim.isIntegerNonBinary(2) );
    185       assert( !fim.isIntegerNonBinary(3) );
    186       assert( !fim.isIntegerNonBinary(4) );
    187 
    188     }
    189     // Test some catches
    190       if (!OsiCbcHasNDEBUG())
    191     { bool thrown ;
    192 
    193       thrown = false ;
    194124      OsiCbcSolverInterface solver;
    195125      try {
    196126        solver.setObjCoeff(0,0.0);
     127        OSIUNITTEST_ADD_OUTCOME("cbc", "setObjCoeff on empty model", "should throw exception", OsiUnitTest::TestOutcome::ERROR, false);
    197128      }
    198129      catch (CoinError e) {
    199         std::cout<<"Correct throw"<<std::endl;
    200         thrown = true ;
    201       }
    202       assert( thrown == true ) ;
     130        if (OsiUnitTest::verbosity >= 1)
     131          std::cout<<"Correct throw from setObjCoeff on empty model"<<std::endl;
     132      }
    203133
    204134      std::string fn = mpsDir+"exmip1";
    205135      solver.readMps(fn.c_str(),"mps");
    206       try {
    207         solver.setObjCoeff(0,0.0);
    208       }
    209       catch (CoinError e) {
    210         std::cout<<"** Incorrect throw"<<std::endl;
    211         abort();
    212       }
    213 
    214       thrown = false ;
     136      OSIUNITTEST_CATCH_ERROR(solver.setObjCoeff(0,0.0), {}, "cbc", "setObjCoeff on nonempty model");
     137
    215138      try {
    216139        int index[]={0,20};
    217140        double value[]={0.0,0.0,0.0,0.0};
    218141        solver.setColSetBounds(index,index+2,value);
     142        OSIUNITTEST_ADD_OUTCOME("cbc", "setColSetBounds on cols not in model", "should throw exception", OsiUnitTest::TestOutcome::ERROR, false);
    219143      }
    220144      catch (CoinError e) {
    221         std::cout<<"Correct throw"<<std::endl;
    222         thrown = true ;
    223       }
    224       assert( thrown == true ) ;
    225     }
    226     // Test apply cuts method
    227     {     
    228       OsiCbcSolverInterface im(m);
    229       OsiCuts cuts;
    230      
    231       // Generate some cuts
    232       {
    233         // Get number of rows and columns in model
    234         int nr=im.getNumRows();
    235         int nc=im.getNumCols();
    236         assert( nr == 5 );
    237         assert( nc == 8 );
    238        
    239         // Generate a valid row cut from thin air
    240         int c;
    241         {
    242           int *inx = new int[nc];
    243           for (c=0;c<nc;c++) inx[c]=c;
    244           double *el = new double[nc];
    245           for (c=0;c<nc;c++) el[c]=((double)c)*((double)c);
    246          
    247           OsiRowCut rc;
    248           rc.setRow(nc,inx,el);
    249           rc.setLb(-100.);
    250           rc.setUb(100.);
    251           rc.setEffectiveness(22);
    252          
    253           cuts.insert(rc);
    254           delete[]el;
    255           delete[]inx;
    256         }
    257        
    258         // Generate valid col cut from thin air
    259         {
    260           const double * oslColLB = im.getColLower();
    261           const double * oslColUB = im.getColUpper();
    262           int *inx = new int[nc];
    263           for (c=0;c<nc;c++) inx[c]=c;
    264           double *lb = new double[nc];
    265           double *ub = new double[nc];
    266           for (c=0;c<nc;c++) lb[c]=oslColLB[c]+0.001;
    267           for (c=0;c<nc;c++) ub[c]=oslColUB[c]-0.001;
    268          
    269           OsiColCut cc;
    270           cc.setLbs(nc,inx,lb);
    271           cc.setUbs(nc,inx,ub);
    272          
    273           cuts.insert(cc);
    274           delete [] ub;
    275           delete [] lb;
    276           delete [] inx;
    277         }
    278        
    279         {
    280           // Generate a row and column cut which are ineffective
    281           OsiRowCut * rcP= new OsiRowCut;
    282           rcP->setEffectiveness(-1.);
    283           cuts.insert(rcP);
    284           assert(rcP==NULL);
    285          
    286           OsiColCut * ccP= new OsiColCut;
    287           ccP->setEffectiveness(-12.);
    288           cuts.insert(ccP);
    289           assert(ccP==NULL);
    290         }
    291         {
    292           //Generate inconsistent Row cut
    293           OsiRowCut rc;
    294           const int ne=1;
    295           int inx[ne]={-10};
    296           double el[ne]={2.5};
    297           rc.setRow(ne,inx,el);
    298           rc.setLb(3.);
    299           rc.setUb(4.);
    300           assert(!rc.consistent());
    301           cuts.insert(rc);
    302         }
    303         {
    304           //Generate inconsistent col cut
    305           OsiColCut cc;
    306           const int ne=1;
    307           int inx[ne]={-10};
    308           double el[ne]={2.5};
    309           cc.setUbs(ne,inx,el);
    310           assert(!cc.consistent());
    311           cuts.insert(cc);
    312         }
    313         {
    314           // Generate row cut which is inconsistent for model m
    315           OsiRowCut rc;
    316           const int ne=1;
    317           int inx[ne]={10};
    318           double el[ne]={2.5};
    319           rc.setRow(ne,inx,el);
    320           assert(rc.consistent());
    321           assert(!rc.consistent(im));
    322           cuts.insert(rc);
    323         }
    324         {
    325           // Generate col cut which is inconsistent for model m
    326           OsiColCut cc;
    327           const int ne=1;
    328           int inx[ne]={30};
    329           double el[ne]={2.0};
    330           cc.setLbs(ne,inx,el);
    331           assert(cc.consistent());
    332           assert(!cc.consistent(im));
    333           cuts.insert(cc);
    334         }
    335         {
    336           // Generate col cut which is infeasible
    337           OsiColCut cc;
    338           const int ne=1;
    339           int inx[ne]={0};
    340           double el[ne]={2.0};
    341           cc.setUbs(ne,inx,el);
    342           cc.setEffectiveness(1000.);
    343           assert(cc.consistent());
    344           assert(cc.consistent(im));
    345           assert(cc.infeasible(im));
    346           cuts.insert(cc);
    347         }
    348       }
    349       assert(cuts.sizeRowCuts()==4);
    350       assert(cuts.sizeColCuts()==5);
    351      
    352       OsiSolverInterface::ApplyCutsReturnCode rc = im.applyCuts(cuts);
    353       assert( rc.getNumIneffective() == 2 );
    354       assert( rc.getNumApplied() == 2 );
    355       assert( rc.getNumInfeasible() == 1 );
    356       assert( rc.getNumInconsistentWrtIntegerModel() == 2 );
    357       assert( rc.getNumInconsistent() == 2 );
    358       assert( cuts.sizeCuts() == rc.getNumIneffective() +
    359         rc.getNumApplied() +
    360         rc.getNumInfeasible() +
    361         rc.getNumInconsistentWrtIntegerModel() +
    362         rc.getNumInconsistent() );
     145        if (OsiUnitTest::verbosity >= 1)
     146          std::cout<<"Correct throw from setObjCoeff on empty model"<<std::endl;
     147      }
    363148    }
    364149   
    365150    {   
    366       OsiCbcSolverInterface oslSi(m);
    367       int nc = oslSi.getNumCols();
    368       int nr = oslSi.getNumRows();
    369       const double * cl = oslSi.getColLower();
    370       const double * cu = oslSi.getColUpper();
    371       const double * rl = oslSi.getRowLower();
    372       const double * ru = oslSi.getRowUpper();
    373       assert( nc == 8 );
    374       assert( nr == 5 );
    375       assert( eq(cl[0],2.5) );
    376       assert( eq(cl[1],0.0) );
    377       assert( eq(cu[1],4.1) );
    378       assert( eq(cu[2],1.0) );
    379       assert( eq(rl[0],2.5) );
    380       assert( eq(rl[4],3.0) );
    381       assert( eq(ru[1],2.1) );
    382       assert( eq(ru[4],15.0) );
    383      
    384       const double * cs = oslSi.getColSolution();
    385       assert( eq(cs[0],2.5) );
    386       assert( eq(cs[7],0.0) );
    387      
    388       assert( !eq(cl[3],1.2345) );
    389       oslSi.setColLower( 3, 1.2345 );
    390       assert( eq(oslSi.getColLower()[3],1.2345) );
    391      
    392       assert( !eq(cu[4],10.2345) );
    393       oslSi.setColUpper( 4, 10.2345 );
    394       assert( eq(oslSi.getColUpper()[4],10.2345) );
    395       // LH: Objective will depend on how underlying solver constructs and
    396       // LH: maintains initial solution.
    397       double objValue = oslSi.getObjValue();
    398       assert( eq(objValue,3.5) || eq(objValue,10.5) );
    399 
    400       assert( eq( oslSi.getObjCoefficients()[0],  1.0) );
    401       assert( eq( oslSi.getObjCoefficients()[1],  0.0) );
    402       assert( eq( oslSi.getObjCoefficients()[2],  0.0) );
    403       assert( eq( oslSi.getObjCoefficients()[3],  0.0) );
    404       assert( eq( oslSi.getObjCoefficients()[4],  2.0) );
    405       assert( eq( oslSi.getObjCoefficients()[5],  0.0) );
    406       assert( eq( oslSi.getObjCoefficients()[6],  0.0) );
    407       assert( eq( oslSi.getObjCoefficients()[7], -1.0) );
     151      OsiCbcSolverInterface cbcSi(m);
     152      int nc = cbcSi.getNumCols();
     153      int nr = cbcSi.getNumRows();
     154      const double * cl = cbcSi.getColLower();
     155      const double * cu = cbcSi.getColUpper();
     156      const double * rl = cbcSi.getRowLower();
     157      const double * ru = cbcSi.getRowUpper();
     158      OSIUNITTEST_ASSERT_ERROR(nc == 8, return 1, "cbc", "read and copy exmip1");
     159      OSIUNITTEST_ASSERT_ERROR(nr == 5, return 1, "cbc", "read and copy exmip1");
     160      OSIUNITTEST_ASSERT_ERROR(eq(cl[0],2.5), {}, "cbc", "read and copy exmip1");
     161      OSIUNITTEST_ASSERT_ERROR(eq(cl[1],0.0), {}, "cbc", "read and copy exmip1");
     162      OSIUNITTEST_ASSERT_ERROR(eq(cu[1],4.1), {}, "cbc", "read and copy exmip1");
     163      OSIUNITTEST_ASSERT_ERROR(eq(cu[2],1.0), {}, "cbc", "read and copy exmip1");
     164      OSIUNITTEST_ASSERT_ERROR(eq(rl[0],2.5), {}, "cbc", "read and copy exmip1");
     165      OSIUNITTEST_ASSERT_ERROR(eq(rl[4],3.0), {}, "cbc", "read and copy exmip1");
     166      OSIUNITTEST_ASSERT_ERROR(eq(ru[1],2.1), {}, "cbc", "read and copy exmip1");
     167      OSIUNITTEST_ASSERT_ERROR(eq(ru[4],15.), {}, "cbc", "read and copy exmip1");
     168     
     169      const double * cs = cbcSi.getColSolution();
     170      OSIUNITTEST_ASSERT_ERROR(eq(cs[0],2.5), {}, "cbc", "read and copy exmip1");
     171      OSIUNITTEST_ASSERT_ERROR(eq(cs[7],0.0), {}, "cbc", "read and copy exmip1");
     172     
     173      OSIUNITTEST_ASSERT_ERROR(!eq(cl[3],1.2345), {}, "cbc", "set col lower");
     174      cbcSi.setColLower( 3, 1.2345 );
     175      OSIUNITTEST_ASSERT_ERROR( eq(cbcSi.getColLower()[3],1.2345), {}, "cbc", "set col lower");
     176     
     177      OSIUNITTEST_ASSERT_ERROR(!eq(cbcSi.getColUpper()[4],10.2345), {}, "cbc", "set col upper");
     178      cbcSi.setColUpper( 4, 10.2345 );
     179      OSIUNITTEST_ASSERT_ERROR( eq(cbcSi.getColUpper()[4],10.2345), {}, "cbc", "set col upper");
     180
     181      // LH: Objective will depend on how underlying solver constructs and maintains initial solution
     182      double objValue = cbcSi.getObjValue();
     183      OSIUNITTEST_ASSERT_ERROR(eq(objValue,3.5) || eq(objValue,10.5), {}, "cbc", "getObjValue() before solve");
     184
     185      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[0], 1.0), {}, "cbc", "read and copy exmip1");
     186      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[1], 0.0), {}, "cbc", "read and copy exmip1");
     187      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[2], 0.0), {}, "cbc", "read and copy exmip1");
     188      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[3], 0.0), {}, "cbc", "read and copy exmip1");
     189      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[4], 2.0), {}, "cbc", "read and copy exmip1");
     190      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[5], 0.0), {}, "cbc", "read and copy exmip1");
     191      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[6], 0.0), {}, "cbc", "read and copy exmip1");
     192      OSIUNITTEST_ASSERT_ERROR(eq(cbcSi.getObjCoefficients()[7],-1.0), {}, "cbc", "read and copy exmip1");
    408193    }
    409194   
     
    412197      const OsiCbcSolverInterface si(m);
    413198      const CoinPackedMatrix * smP = si.getMatrixByRow();
    414       // LL:      const OsiCbcPackedMatrix * osmP = dynamic_cast<const OsiCbcPackedMatrix*>(smP);
    415       // LL: assert( osmP!=NULL );
     199
     200      OSIUNITTEST_ASSERT_ERROR(smP->getMajorDim()    ==  5, return 1, "cbc", "getMatrixByRow: major dim");
     201      OSIUNITTEST_ASSERT_ERROR(smP->getMinorDim()    ==  8, return 1, "cbc", "getMatrixByRow: major dim");
     202      OSIUNITTEST_ASSERT_ERROR(smP->getNumElements() == 14, return 1, "cbc", "getMatrixByRow: num elements");
     203      OSIUNITTEST_ASSERT_ERROR(smP->getSizeVectorStarts() == 6, return 1, "cbc", "getMatrixByRow: num elements");
    416204
    417205#ifdef OSICBC_TEST_MTX_STRUCTURE
    418 
    419206      CoinRelFltEq eq;
    420207      const double * ev = smP->getElements();
    421       assert( eq(ev[0],   3.0) );
    422       assert( eq(ev[1],   1.0) );
    423       assert( eq(ev[2],  -2.0) );
    424       assert( eq(ev[3],  -1.0) );
    425       assert( eq(ev[4],  -1.0) );
    426       assert( eq(ev[5],   2.0) );
    427       assert( eq(ev[6],   1.1) );
    428       assert( eq(ev[7],   1.0) );
    429       assert( eq(ev[8],   1.0) );
    430       assert( eq(ev[9],   2.8) );
    431       assert( eq(ev[10], -1.2) );
    432       assert( eq(ev[11],  5.6) );
    433       assert( eq(ev[12],  1.0) );
    434       assert( eq(ev[13],  1.9) );
    435      
    436       const CoinBigIndex * mi = smP->getVectorStarts();
    437       assert( mi[0]==0 );
    438       assert( mi[1]==5 );
    439       assert( mi[2]==7 );
    440       assert( mi[3]==9 );
    441       assert( mi[4]==11 );
    442       assert( mi[5]==14 );
     208      OSIUNITTEST_ASSERT_ERROR(eq(ev[0],   3.0), {}, "cbc", "getMatrixByRow: elements");
     209      OSIUNITTEST_ASSERT_ERROR(eq(ev[1],   1.0), {}, "cbc", "getMatrixByRow: elements");
     210      OSIUNITTEST_ASSERT_ERROR(eq(ev[2],  -2.0), {}, "cbc", "getMatrixByRow: elements");
     211      OSIUNITTEST_ASSERT_ERROR(eq(ev[3],  -1.0), {}, "cbc", "getMatrixByRow: elements");
     212      OSIUNITTEST_ASSERT_ERROR(eq(ev[4],  -1.0), {}, "cbc", "getMatrixByRow: elements");
     213      OSIUNITTEST_ASSERT_ERROR(eq(ev[5],   2.0), {}, "cbc", "getMatrixByRow: elements");
     214      OSIUNITTEST_ASSERT_ERROR(eq(ev[6],   1.1), {}, "cbc", "getMatrixByRow: elements");
     215      OSIUNITTEST_ASSERT_ERROR(eq(ev[7],   1.0), {}, "cbc", "getMatrixByRow: elements");
     216      OSIUNITTEST_ASSERT_ERROR(eq(ev[8],   1.0), {}, "cbc", "getMatrixByRow: elements");
     217      OSIUNITTEST_ASSERT_ERROR(eq(ev[9],   2.8), {}, "cbc", "getMatrixByRow: elements");
     218      OSIUNITTEST_ASSERT_ERROR(eq(ev[10], -1.2), {}, "cbc", "getMatrixByRow: elements");
     219      OSIUNITTEST_ASSERT_ERROR(eq(ev[11],  5.6), {}, "cbc", "getMatrixByRow: elements");
     220      OSIUNITTEST_ASSERT_ERROR(eq(ev[12],  1.0), {}, "cbc", "getMatrixByRow: elements");
     221      OSIUNITTEST_ASSERT_ERROR(eq(ev[13],  1.9), {}, "cbc", "getMatrixByRow: elements");
     222     
     223      const int * mi = smP->getVectorStarts();
     224      OSIUNITTEST_ASSERT_ERROR(mi[0] ==  0, {}, "cbc", "getMatrixByRow: vector starts");
     225      OSIUNITTEST_ASSERT_ERROR(mi[1] ==  5, {}, "cbc", "getMatrixByRow: vector starts");
     226      OSIUNITTEST_ASSERT_ERROR(mi[2] ==  7, {}, "cbc", "getMatrixByRow: vector starts");
     227      OSIUNITTEST_ASSERT_ERROR(mi[3] ==  9, {}, "cbc", "getMatrixByRow: vector starts");
     228      OSIUNITTEST_ASSERT_ERROR(mi[4] == 11, {}, "cbc", "getMatrixByRow: vector starts");
     229      OSIUNITTEST_ASSERT_ERROR(mi[5] == 14, {}, "cbc", "getMatrixByRow: vector starts");
    443230     
    444231      const int * ei = smP->getIndices();
    445       assert( ei[0]  ==  0 );
    446       assert( ei[1]  ==  1 );
    447       assert( ei[2]  ==  3 );
    448       assert( ei[3]  ==  4 );
    449       assert( ei[4]  ==  7 );
    450       assert( ei[5]  ==  1 );
    451       assert( ei[6]  ==  2 );
    452       assert( ei[7]  ==  2 );
    453       assert( ei[8]  ==  5 );
    454       assert( ei[9]  ==  3 );
    455       assert( ei[10] ==  6 );
    456       assert( ei[11] ==  0 );
    457       assert( ei[12] ==  4 );
    458       assert( ei[13] ==  7 );   
    459 
     232      OSIUNITTEST_ASSERT_ERROR(ei[ 0] == 0, {}, "cbc", "getMatrixByRow: indices");
     233      OSIUNITTEST_ASSERT_ERROR(ei[ 1] == 1, {}, "cbc", "getMatrixByRow: indices");
     234      OSIUNITTEST_ASSERT_ERROR(ei[ 2] == 3, {}, "cbc", "getMatrixByRow: indices");
     235      OSIUNITTEST_ASSERT_ERROR(ei[ 3] == 4, {}, "cbc", "getMatrixByRow: indices");
     236      OSIUNITTEST_ASSERT_ERROR(ei[ 4] == 7, {}, "cbc", "getMatrixByRow: indices");
     237      OSIUNITTEST_ASSERT_ERROR(ei[ 5] == 1, {}, "cbc", "getMatrixByRow: indices");
     238      OSIUNITTEST_ASSERT_ERROR(ei[ 6] == 2, {}, "cbc", "getMatrixByRow: indices");
     239      OSIUNITTEST_ASSERT_ERROR(ei[ 7] == 2, {}, "cbc", "getMatrixByRow: indices");
     240      OSIUNITTEST_ASSERT_ERROR(ei[ 8] == 5, {}, "cbc", "getMatrixByRow: indices");
     241      OSIUNITTEST_ASSERT_ERROR(ei[ 9] == 3, {}, "cbc", "getMatrixByRow: indices");
     242      OSIUNITTEST_ASSERT_ERROR(ei[10] == 6, {}, "cbc", "getMatrixByRow: indices");
     243      OSIUNITTEST_ASSERT_ERROR(ei[11] == 0, {}, "cbc", "getMatrixByRow: indices");
     244      OSIUNITTEST_ASSERT_ERROR(ei[12] == 4, {}, "cbc", "getMatrixByRow: indices");
     245      OSIUNITTEST_ASSERT_ERROR(ei[13] == 7, {}, "cbc", "getMatrixByRow: indices");
    460246#else   // OSICBC_TEST_MTX_STRUCTURE
    461247
    462248      CoinPackedMatrix exmip1Mtx ;
    463249      exmip1Mtx.reverseOrderedCopyOf(BuildExmip1Mtx()) ;
    464       assert( exmip1Mtx.isEquivalent(*smP) ) ;
    465 
     250      OSIUNITTEST_ASSERT_ERROR(exmip1Mtx.isEquivalent(*smP), {}, "cbc", "getMatrixByRow") ;
    466251#endif  // OSICBC_TEST_MTX_STRUCTURE
    467 
    468       assert( smP->getMajorDim() == 5 );
    469       assert( smP->getMinorDim() == 8 );
    470       assert( smP->getNumElements() == 14 );
    471       assert( smP->getSizeVectorStarts() == 6 );
    472252    }
    473253
     
    514294      const double * cs = fim.getColSolution();
    515295      CoinRelFltEq eq;
    516       assert( eq(cs[2],   1.0) );
    517       assert( eq(cs[3],   1.0) );
     296      OSIUNITTEST_ASSERT_ERROR(eq(cs[2], 1.0), {}, "cbc", "add cuts");
     297      OSIUNITTEST_ASSERT_ERROR(eq(cs[3], 1.0), {}, "cbc", "add cuts");
    518298      // check will find invalid matrix
    519299      el[0]=1.0/el[4];
     
    526306      // resolve - should get message about zero elements
    527307      fim.resolve();
    528       assert (fim.isAbandoned());
     308      OSIUNITTEST_ASSERT_WARNING(fim.isAbandoned(), {}, "cbc", "add cuts");
    529309      delete[]el;
    530310      delete[]inx;
    531311    }
    532312
    533         // Test matrixByCol method
     313    // Test matrixByCol method
    534314    {
    535  
    536315      const OsiCbcSolverInterface si(m);
    537316      const CoinPackedMatrix * smP = si.getMatrixByCol();
    538       // LL:      const OsiCbcPackedMatrix * osmP = dynamic_cast<const OsiCbcPackedMatrix*>(smP);
    539       // LL: assert( osmP!=NULL );
    540      
     317
     318      OSIUNITTEST_ASSERT_ERROR(smP->getMajorDim()    ==  8, return 1, "cbc", "getMatrixByCol: major dim");
     319      OSIUNITTEST_ASSERT_ERROR(smP->getMinorDim()    ==  5, return 1, "cbc", "getMatrixByCol: minor dim");
     320      OSIUNITTEST_ASSERT_ERROR(smP->getNumElements() == 14, return 1, "cbc", "getMatrixByCol: number of elements");
     321      OSIUNITTEST_ASSERT_ERROR(smP->getSizeVectorStarts() == 9, return 1, "cbc", "getMatrixByCol: vector starts size");
     322
    541323#ifdef OSICBC_TEST_MTX_STRUCTURE
    542 
    543324      CoinRelFltEq eq;
    544325      const double * ev = smP->getElements();
    545       assert( eq(ev[0],   3.0) );
    546       assert( eq(ev[1],   5.6) );
    547       assert( eq(ev[2],   1.0) );
    548       assert( eq(ev[3],   2.0) );
    549       assert( eq(ev[4],   1.1) );
    550       assert( eq(ev[5],   1.0) );
    551       assert( eq(ev[6],  -2.0) );
    552       assert( eq(ev[7],   2.8) );
    553       assert( eq(ev[8],  -1.0) );
    554       assert( eq(ev[9],   1.0) );
    555       assert( eq(ev[10],  1.0) );
    556       assert( eq(ev[11], -1.2) );
    557       assert( eq(ev[12], -1.0) );
    558       assert( eq(ev[13],  1.9) );
     326      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 0], 3.0), {}, "cbc", "getMatrixByCol: elements");
     327      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 1], 5.6), {}, "cbc", "getMatrixByCol: elements");
     328      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 2], 1.0), {}, "cbc", "getMatrixByCol: elements");
     329      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 3], 2.0), {}, "cbc", "getMatrixByCol: elements");
     330      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 4], 1.1), {}, "cbc", "getMatrixByCol: elements");
     331      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 5], 1.0), {}, "cbc", "getMatrixByCol: elements");
     332      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 6],-2.0), {}, "cbc", "getMatrixByCol: elements");
     333      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 7], 2.8), {}, "cbc", "getMatrixByCol: elements");
     334      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 8],-1.0), {}, "cbc", "getMatrixByCol: elements");
     335      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 9], 1.0), {}, "cbc", "getMatrixByCol: elements");
     336      OSIUNITTEST_ASSERT_ERROR(eq(ev[10], 1.0), {}, "cbc", "getMatrixByCol: elements");
     337      OSIUNITTEST_ASSERT_ERROR(eq(ev[11],-1.2), {}, "cbc", "getMatrixByCol: elements");
     338      OSIUNITTEST_ASSERT_ERROR(eq(ev[12],-1.0), {}, "cbc", "getMatrixByCol: elements");
     339      OSIUNITTEST_ASSERT_ERROR(eq(ev[13], 1.9), {}, "cbc", "getMatrixByCol: elements");
    559340     
    560341      const CoinBigIndex * mi = smP->getVectorStarts();
    561       assert( mi[0]==0 );
    562       assert( mi[1]==2 );
    563       assert( mi[2]==4 );
    564       assert( mi[3]==6 );
    565       assert( mi[4]==8 );
    566       assert( mi[5]==10 );
    567       assert( mi[6]==11 );
    568       assert( mi[7]==12 );
    569       assert( mi[8]==14 );
     342      OSIUNITTEST_ASSERT_ERROR(mi[0] ==  0, {}, "cbc", "getMatrixByCol: vector starts");
     343      OSIUNITTEST_ASSERT_ERROR(mi[1] ==  2, {}, "cbc", "getMatrixByCol: vector starts");
     344      OSIUNITTEST_ASSERT_ERROR(mi[2] ==  4, {}, "cbc", "getMatrixByCol: vector starts");
     345      OSIUNITTEST_ASSERT_ERROR(mi[3] ==  6, {}, "cbc", "getMatrixByCol: vector starts");
     346      OSIUNITTEST_ASSERT_ERROR(mi[4] ==  8, {}, "cbc", "getMatrixByCol: vector starts");
     347      OSIUNITTEST_ASSERT_ERROR(mi[5] == 10, {}, "cbc", "getMatrixByCol: vector starts");
     348      OSIUNITTEST_ASSERT_ERROR(mi[6] == 11, {}, "cbc", "getMatrixByCol: vector starts");
     349      OSIUNITTEST_ASSERT_ERROR(mi[7] == 12, {}, "cbc", "getMatrixByCol: vector starts");
     350      OSIUNITTEST_ASSERT_ERROR(mi[8] == 14, {}, "cbc", "getMatrixByCol: vector starts");
    570351     
    571352      const int * ei = smP->getIndices();
    572       assert( ei[0]  ==  0 );
    573       assert( ei[1]  ==  4 );
    574       assert( ei[2]  ==  0 );
    575       assert( ei[3]  ==  1 );
    576       assert( ei[4]  ==  1 );
    577       assert( ei[5]  ==  2 );
    578       assert( ei[6]  ==  0 );
    579       assert( ei[7]  ==  3 );
    580       assert( ei[8]  ==  0 );
    581       assert( ei[9]  ==  4 );
    582       assert( ei[10] ==  2 );
    583       assert( ei[11] ==  3 );
    584       assert( ei[12] ==  0 );
    585       assert( ei[13] ==  4 );   
    586      
     353      OSIUNITTEST_ASSERT_ERROR(ei[ 0] == 0, {}, "cbc", "getMatrixByCol: indices");
     354      OSIUNITTEST_ASSERT_ERROR(ei[ 1] == 4, {}, "cbc", "getMatrixByCol: indices");
     355      OSIUNITTEST_ASSERT_ERROR(ei[ 2] == 0, {}, "cbc", "getMatrixByCol: indices");
     356      OSIUNITTEST_ASSERT_ERROR(ei[ 3] == 1, {}, "cbc", "getMatrixByCol: indices");
     357      OSIUNITTEST_ASSERT_ERROR(ei[ 4] == 1, {}, "cbc", "getMatrixByCol: indices");
     358      OSIUNITTEST_ASSERT_ERROR(ei[ 5] == 2, {}, "cbc", "getMatrixByCol: indices");
     359      OSIUNITTEST_ASSERT_ERROR(ei[ 6] == 0, {}, "cbc", "getMatrixByCol: indices");
     360      OSIUNITTEST_ASSERT_ERROR(ei[ 7] == 3, {}, "cbc", "getMatrixByCol: indices");
     361      OSIUNITTEST_ASSERT_ERROR(ei[ 8] == 0, {}, "cbc", "getMatrixByCol: indices");
     362      OSIUNITTEST_ASSERT_ERROR(ei[ 9] == 4, {}, "cbc", "getMatrixByCol: indices");
     363      OSIUNITTEST_ASSERT_ERROR(ei[10] == 2, {}, "cbc", "getMatrixByCol: indices");
     364      OSIUNITTEST_ASSERT_ERROR(ei[11] == 3, {}, "cbc", "getMatrixByCol: indices");
     365      OSIUNITTEST_ASSERT_ERROR(ei[12] == 0, {}, "cbc", "getMatrixByCol: indices");
     366      OSIUNITTEST_ASSERT_ERROR(ei[13] == 4, {}, "cbc", "getMatrixByCol: indices");
    587367#else // OSICBC_TEST_MTX_STRUCTURE
    588368
    589369      CoinPackedMatrix &exmip1Mtx = BuildExmip1Mtx() ;
    590       assert( exmip1Mtx.isEquivalent(*smP) ) ;
    591 
     370      OSIUNITTEST_ASSERT_ERROR(exmip1Mtx.isEquivalent(*smP), {}, "cbc", "getMatrixByCol");
    592371#endif  // OSICBC_TEST_MTX_STRUCTURE     
    593 
    594       assert( smP->getMajorDim() == 8 );
    595       assert( smP->getMinorDim() == 5 );
    596       assert( smP->getNumElements() == 14 );
    597       assert( smP->getSizeVectorStarts() == 9 );
    598372    }
    599373
     
    602376    {
    603377      OsiCbcSolverInterface lhs;
    604       {     
    605 
    606         OsiCbcSolverInterface siC1(m);     
     378      {
     379        OsiCbcSolverInterface siC1(m);
     380
    607381        const char   * siC1rs  = siC1.getRowSense();
    608         assert( siC1rs[0]=='G' );
    609         assert( siC1rs[1]=='L' );
    610         assert( siC1rs[2]=='E' );
    611         assert( siC1rs[3]=='R' );
    612         assert( siC1rs[4]=='R' );
    613        
     382        OSIUNITTEST_ASSERT_ERROR(siC1rs[0] == 'G', {}, "cbc", "row sense");
     383        OSIUNITTEST_ASSERT_ERROR(siC1rs[1] == 'L', {}, "cbc", "row sense");
     384        OSIUNITTEST_ASSERT_ERROR(siC1rs[2] == 'E', {}, "cbc", "row sense");
     385        OSIUNITTEST_ASSERT_ERROR(siC1rs[3] == 'R', {}, "cbc", "row sense");
     386        OSIUNITTEST_ASSERT_ERROR(siC1rs[4] == 'R', {}, "cbc", "row sense");
     387
    614388        const double * siC1rhs = siC1.getRightHandSide();
    615         assert( eq(siC1rhs[0],2.5) );
    616         assert( eq(siC1rhs[1],2.1) );
    617         assert( eq(siC1rhs[2],4.0) );
    618         assert( eq(siC1rhs[3],5.0) );
    619         assert( eq(siC1rhs[4],15.) );
    620        
     389        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[0],2.5), {}, "cbc", "right hand side");
     390        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[1],2.1), {}, "cbc", "right hand side");
     391        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[2],4.0), {}, "cbc", "right hand side");
     392        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[3],5.0), {}, "cbc", "right hand side");
     393        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[4],15.), {}, "cbc", "right hand side");
     394
    621395        const double * siC1rr  = siC1.getRowRange();
    622         assert( eq(siC1rr[0],0.0) );
    623         assert( eq(siC1rr[1],0.0) );
    624         assert( eq(siC1rr[2],0.0) );
    625         assert( eq(siC1rr[3],5.0-1.8) );
    626         assert( eq(siC1rr[4],15.0-3.0) );
     396        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[0],0.0), {}, "cbc", "row range");
     397        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[1],0.0), {}, "cbc", "row range");
     398        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[2],0.0), {}, "cbc", "row range");
     399        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[3],5.0-1.8), {}, "cbc", "row range");
     400        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[4],15.0-3.0), {}, "cbc", "row range");
    627401       
    628402        const CoinPackedMatrix * siC1mbr = siC1.getMatrixByRow();
    629         assert( siC1mbr != NULL );
     403        OSIUNITTEST_ASSERT_ERROR(siC1mbr != NULL, {}, "cbc", "matrix by row");
     404        OSIUNITTEST_ASSERT_ERROR(siC1mbr->getMajorDim()    ==  5, return 1, "cbc", "matrix by row: major dim");
     405        OSIUNITTEST_ASSERT_ERROR(siC1mbr->getMinorDim()    ==  8, return 1, "cbc", "matrix by row: major dim");
     406        OSIUNITTEST_ASSERT_ERROR(siC1mbr->getNumElements() == 14, return 1, "cbc", "matrix by row: num elements");
     407        OSIUNITTEST_ASSERT_ERROR(siC1mbr->getSizeVectorStarts() == 6, return 1, "cbc", "matrix by row: num elements");
    630408
    631409#ifdef OSICBC_TEST_MTX_STRUCTURE
    632 
    633410        const double * ev = siC1mbr->getElements();
    634         assert( eq(ev[0],   3.0) );
    635         assert( eq(ev[1],   1.0) );
    636         assert( eq(ev[2],  -2.0) );
    637         assert( eq(ev[3],  -1.0) );
    638         assert( eq(ev[4],  -1.0) );
    639         assert( eq(ev[5],   2.0) );
    640         assert( eq(ev[6],   1.1) );
    641         assert( eq(ev[7],   1.0) );
    642         assert( eq(ev[8],   1.0) );
    643         assert( eq(ev[9],   2.8) );
    644         assert( eq(ev[10], -1.2) );
    645         assert( eq(ev[11],  5.6) );
    646         assert( eq(ev[12],  1.0) );
    647         assert( eq(ev[13],  1.9) );
    648        
     411        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 0], 3.0), {}, "cbc", "matrix by row: elements");
     412        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 1], 1.0), {}, "cbc", "matrix by row: elements");
     413        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 2],-2.0), {}, "cbc", "matrix by row: elements");
     414        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 3],-1.0), {}, "cbc", "matrix by row: elements");
     415        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 4],-1.0), {}, "cbc", "matrix by row: elements");
     416        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 5], 2.0), {}, "cbc", "matrix by row: elements");
     417        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 6], 1.1), {}, "cbc", "matrix by row: elements");
     418        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 7], 1.0), {}, "cbc", "matrix by row: elements");
     419        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 8], 1.0), {}, "cbc", "matrix by row: elements");
     420        OSIUNITTEST_ASSERT_ERROR(eq(ev[ 9], 2.8), {}, "cbc", "matrix by row: elements");
     421        OSIUNITTEST_ASSERT_ERROR(eq(ev[10],-1.2), {}, "cbc", "matrix by row: elements");
     422        OSIUNITTEST_ASSERT_ERROR(eq(ev[11], 5.6), {}, "cbc", "matrix by row: elements");
     423        OSIUNITTEST_ASSERT_ERROR(eq(ev[12], 1.0), {}, "cbc", "matrix by row: elements");
     424        OSIUNITTEST_ASSERT_ERROR(eq(ev[13], 1.9), {}, "cbc", "matrix by row: elements");
     425
    649426        const CoinBigIndex * mi = siC1mbr->getVectorStarts();
    650         assert( mi[0]==0 );
    651         assert( mi[1]==5 );
    652         assert( mi[2]==7 );
    653         assert( mi[3]==9 );
    654         assert( mi[4]==11 );
    655         assert( mi[5]==14 );
    656        
     427        OSIUNITTEST_ASSERT_ERROR(mi[0] ==  0, {}, "cbc", "matrix by row: vector starts");
     428        OSIUNITTEST_ASSERT_ERROR(mi[1] ==  5, {}, "cbc", "matrix by row: vector starts");
     429        OSIUNITTEST_ASSERT_ERROR(mi[2] ==  7, {}, "cbc", "matrix by row: vector starts");
     430        OSIUNITTEST_ASSERT_ERROR(mi[3] ==  9, {}, "cbc", "matrix by row: vector starts");
     431        OSIUNITTEST_ASSERT_ERROR(mi[4] == 11, {}, "cbc", "matrix by row: vector starts");
     432        OSIUNITTEST_ASSERT_ERROR(mi[5] == 14, {}, "cbc", "matrix by row: vector starts");
     433
    657434        const int * ei = siC1mbr->getIndices();
    658         assert( ei[0]  ==  0 );
    659         assert( ei[1]  ==  1 );
    660         assert( ei[2]  ==  3 );
    661         assert( ei[3]  ==  4 );
    662         assert( ei[4]  ==  7 );
    663         assert( ei[5]  ==  1 );
    664         assert( ei[6]  ==  2 );
    665         assert( ei[7]  ==  2 );
    666         assert( ei[8]  ==  5 );
    667         assert( ei[9]  ==  3 );
    668         assert( ei[10] ==  6 );
    669         assert( ei[11] ==  0 );
    670         assert( ei[12] ==  4 );
    671         assert( ei[13] ==  7 );   
    672 
     435        OSIUNITTEST_ASSERT_ERROR(ei[ 0] == 0, {}, "cbc", "matrix by row: indices");
     436        OSIUNITTEST_ASSERT_ERROR(ei[ 1] == 1, {}, "cbc", "matrix by row: indices");
     437        OSIUNITTEST_ASSERT_ERROR(ei[ 2] == 3, {}, "cbc", "matrix by row: indices");
     438        OSIUNITTEST_ASSERT_ERROR(ei[ 3] == 4, {}, "cbc", "matrix by row: indices");
     439        OSIUNITTEST_ASSERT_ERROR(ei[ 4] == 7, {}, "cbc", "matrix by row: indices");
     440        OSIUNITTEST_ASSERT_ERROR(ei[ 5] == 1, {}, "cbc", "matrix by row: indices");
     441        OSIUNITTEST_ASSERT_ERROR(ei[ 6] == 2, {}, "cbc", "matrix by row: indices");
     442        OSIUNITTEST_ASSERT_ERROR(ei[ 7] == 2, {}, "cbc", "matrix by row: indices");
     443        OSIUNITTEST_ASSERT_ERROR(ei[ 8] == 5, {}, "cbc", "matrix by row: indices");
     444        OSIUNITTEST_ASSERT_ERROR(ei[ 9] == 3, {}, "cbc", "matrix by row: indices");
     445        OSIUNITTEST_ASSERT_ERROR(ei[10] == 6, {}, "cbc", "matrix by row: indices");
     446        OSIUNITTEST_ASSERT_ERROR(ei[11] == 0, {}, "cbc", "matrix by row: indices");
     447        OSIUNITTEST_ASSERT_ERROR(ei[12] == 4, {}, "cbc", "matrix by row: indices");
     448        OSIUNITTEST_ASSERT_ERROR(ei[13] == 7, {}, "cbc", "matrix by row: indices");
    673449#else   // OSICBC_TEST_MTX_STRUCTURE
    674450
    675         CoinPackedMatrix exmip1Mtx ;
    676         exmip1Mtx.reverseOrderedCopyOf(BuildExmip1Mtx()) ;
    677         assert( exmip1Mtx.isEquivalent(*siC1mbr) ) ;
    678 
     451        CoinPackedMatrix exmip1Mtx ;
     452        exmip1Mtx.reverseOrderedCopyOf(BuildExmip1Mtx()) ;
     453        OSIUNITTEST_ASSERT_ERROR(exmip1Mtx.isEquivalent(*siC1mbr), {}, "cbc", "matrix by row");
    679454#endif  // OSICBC_TEST_MTX_STRUCTURE
    680455
    681         assert( siC1mbr->getMajorDim() == 5 );
    682         assert( siC1mbr->getMinorDim() == 8 );
    683         assert( siC1mbr->getNumElements() == 14 );
    684         assert( siC1mbr->getSizeVectorStarts()==6 );
    685 
    686         assert( siC1rs  == siC1.getRowSense() );
    687         assert( siC1rhs == siC1.getRightHandSide() );
    688         assert( siC1rr  == siC1.getRowRange() );
    689 
    690         // Change OSL Model by adding free row
     456        OSIUNITTEST_ASSERT_WARNING(siC1rs  == siC1.getRowSense(), {}, "cbc", "row sense");
     457        OSIUNITTEST_ASSERT_WARNING(siC1rhs == siC1.getRightHandSide(), {}, "cbc", "right hand side");
     458        OSIUNITTEST_ASSERT_WARNING(siC1rr  == siC1.getRowRange(), {}, "cbc", "row range");
     459
     460        // Change CBC Model by adding free row
    691461        OsiRowCut rc;
    692         rc.setLb(-DBL_MAX);
    693         rc.setUb( DBL_MAX);
     462        rc.setLb(-COIN_DBL_MAX);
     463        rc.setUb( COIN_DBL_MAX);
    694464        OsiCuts cuts;
    695465        cuts.insert(rc);
    696466        siC1.applyCuts(cuts);
    697              
    698        
     467
    699468        siC1rs  = siC1.getRowSense();
    700         assert( siC1rs[0]=='G' );
    701         assert( siC1rs[1]=='L' );
    702         assert( siC1rs[2]=='E' );
    703         assert( siC1rs[3]=='R' );
    704         assert( siC1rs[4]=='R' );
    705         assert( siC1rs[5]=='N' );
     469        OSIUNITTEST_ASSERT_ERROR(siC1rs[0] == 'G', {}, "cbc", "row sense after adding row");
     470        OSIUNITTEST_ASSERT_ERROR(siC1rs[1] == 'L', {}, "cbc", "row sense after adding row");
     471        OSIUNITTEST_ASSERT_ERROR(siC1rs[2] == 'E', {}, "cbc", "row sense after adding row");
     472        OSIUNITTEST_ASSERT_ERROR(siC1rs[3] == 'R', {}, "cbc", "row sense after adding row");
     473        OSIUNITTEST_ASSERT_ERROR(siC1rs[4] == 'R', {}, "cbc", "row sense after adding row");
     474        OSIUNITTEST_ASSERT_ERROR(siC1rs[5] == 'N', {}, "cbc", "row sense after adding row");
    706475
    707476        siC1rhs = siC1.getRightHandSide();
    708         assert( eq(siC1rhs[0],2.5) );
    709         assert( eq(siC1rhs[1],2.1) );
    710         assert( eq(siC1rhs[2],4.0) );
    711         assert( eq(siC1rhs[3],5.0) );
    712         assert( eq(siC1rhs[4],15.) );
    713         assert( eq(siC1rhs[5],0.0 ) );
     477        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[0],2.5), {}, "cbc", "right hand side after adding row");
     478        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[1],2.1), {}, "cbc", "right hand side after adding row");
     479        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[2],4.0), {}, "cbc", "right hand side after adding row");
     480        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[3],5.0), {}, "cbc", "right hand side after adding row");
     481        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[4],15.), {}, "cbc", "right hand side after adding row");
     482        OSIUNITTEST_ASSERT_ERROR(eq(siC1rhs[5],0.0), {}, "cbc", "right hand side after adding row");
    714483
    715484        siC1rr  = siC1.getRowRange();
    716         assert( eq(siC1rr[0],0.0) );
    717         assert( eq(siC1rr[1],0.0) );
    718         assert( eq(siC1rr[2],0.0) );
    719         assert( eq(siC1rr[3],5.0-1.8) );
    720         assert( eq(siC1rr[4],15.0-3.0) );
    721         assert( eq(siC1rr[5],0.0) );
    722    
    723         lhs=siC1;
    724       }
     485        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[0],0.0), {}, "cbc", "row range after adding row");
     486        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[1],0.0), {}, "cbc", "row range after adding row");
     487        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[2],0.0), {}, "cbc", "row range after adding row");
     488        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[3],5.0-1.8), {}, "cbc", "row range after adding row");
     489        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[4],15.0-3.0), {}, "cbc", "row range after adding row");
     490        OSIUNITTEST_ASSERT_ERROR(eq(siC1rr[5],0.0), {}, "cbc", "row range after adding row");
     491
     492        lhs = siC1;
     493      }
     494
    725495      // Test that lhs has correct values even though siC1 has gone out of scope   
    726      
    727496      const char * lhsrs  = lhs.getRowSense();
    728       assert( lhsrs[0]=='G' );
    729       assert( lhsrs[1]=='L' );
    730       assert( lhsrs[2]=='E' );
    731       assert( lhsrs[3]=='R' );
    732       assert( lhsrs[4]=='R' );
    733       assert( lhsrs[5]=='N' );
     497      OSIUNITTEST_ASSERT_ERROR(lhsrs[0] == 'G', {}, "cbc", "row sense after assignment");
     498      OSIUNITTEST_ASSERT_ERROR(lhsrs[1] == 'L', {}, "cbc", "row sense after assignment");
     499      OSIUNITTEST_ASSERT_ERROR(lhsrs[2] == 'E', {}, "cbc", "row sense after assignment");
     500      OSIUNITTEST_ASSERT_ERROR(lhsrs[3] == 'R', {}, "cbc", "row sense after assignment");
     501      OSIUNITTEST_ASSERT_ERROR(lhsrs[4] == 'R', {}, "cbc", "row sense after assignment");
     502      OSIUNITTEST_ASSERT_ERROR(lhsrs[5] == 'N', {}, "cbc", "row sense after assignment");
    734503     
    735504      const double * lhsrhs = lhs.getRightHandSide();
    736       assert( eq(lhsrhs[0],2.5) );
    737       assert( eq(lhsrhs[1],2.1) );
    738       assert( eq(lhsrhs[2],4.0) );
    739       assert( eq(lhsrhs[3],5.0) );
    740       assert( eq(lhsrhs[4],15.) );
    741       assert( eq(lhsrhs[5],0.0) );
    742      
    743       const double *lhsrr  = lhs.getRowRange();
    744       assert( eq(lhsrr[0],0.0) );
    745       assert( eq(lhsrr[1],0.0) );
    746       assert( eq(lhsrr[2],0.0) );
    747       assert( eq(lhsrr[3],5.0-1.8) );
    748       assert( eq(lhsrr[4],15.0-3.0) );
    749       assert( eq(lhsrr[5],0.0) );     
     505      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[0],2.5), {}, "cbc", "right hand side after assignment");
     506      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[1],2.1), {}, "cbc", "right hand side after assignment");
     507      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[2],4.0), {}, "cbc", "right hand side after assignment");
     508      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[3],5.0), {}, "cbc", "right hand side after assignment");
     509      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[4],15.), {}, "cbc", "right hand side after assignment");
     510      OSIUNITTEST_ASSERT_ERROR(eq(lhsrhs[5],0.0), {}, "cbc", "right hand side after assignment");
     511     
     512      const double *lhsrr = lhs.getRowRange();
     513      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[0],0.0), {}, "cbc", "row range after assignment");
     514      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[1],0.0), {}, "cbc", "row range after assignment");
     515      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[2],0.0), {}, "cbc", "row range after assignment");
     516      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[3],5.0-1.8), {}, "cbc", "row range after assignment");
     517      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[4],15.0-3.0), {}, "cbc", "row range after assignment");
     518      OSIUNITTEST_ASSERT_ERROR(eq(lhsrr[5],0.0), {}, "cbc", "row range after assignment");
    750519     
    751520      const CoinPackedMatrix * lhsmbr = lhs.getMatrixByRow();
    752       assert( lhsmbr != NULL );       
     521      OSIUNITTEST_ASSERT_ERROR(lhsmbr != NULL, {}, "cbc", "matrix by row after assignment");
     522      OSIUNITTEST_ASSERT_ERROR(lhsmbr->getMajorDim()    ==  6, return 1, "cbc", "matrix by row after assignment: major dim");
     523      OSIUNITTEST_ASSERT_ERROR(lhsmbr->getNumElements() == 14, return 1, "cbc", "matrix by row after assignment: num elements");
     524
    753525
    754526#ifdef OSICBC_TEST_MTX_STRUCTURE
    755 
    756527      const double * ev = lhsmbr->getElements();
    757       assert( eq(ev[0],   3.0) );
    758       assert( eq(ev[1],   1.0) );
    759       assert( eq(ev[2],  -2.0) );
    760       assert( eq(ev[3],  -1.0) );
    761       assert( eq(ev[4],  -1.0) );
    762       assert( eq(ev[5],   2.0) );
    763       assert( eq(ev[6],   1.1) );
    764       assert( eq(ev[7],   1.0) );
    765       assert( eq(ev[8],   1.0) );
    766       assert( eq(ev[9],   2.8) );
    767       assert( eq(ev[10], -1.2) );
    768       assert( eq(ev[11],  5.6) );
    769       assert( eq(ev[12],  1.0) );
    770       assert( eq(ev[13],  1.9) );
     528      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 0], 3.0), {}, "cbc", "matrix by row after assignment: elements");
     529      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 1], 1.0), {}, "cbc", "matrix by row after assignment: elements");
     530      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 2],-2.0), {}, "cbc", "matrix by row after assignment: elements");
     531      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 3],-1.0), {}, "cbc", "matrix by row after assignment: elements");
     532      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 4],-1.0), {}, "cbc", "matrix by row after assignment: elements");
     533      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 5], 2.0), {}, "cbc", "matrix by row after assignment: elements");
     534      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 6], 1.1), {}, "cbc", "matrix by row after assignment: elements");
     535      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 7], 1.0), {}, "cbc", "matrix by row after assignment: elements");
     536      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 8], 1.0), {}, "cbc", "matrix by row after assignment: elements");
     537      OSIUNITTEST_ASSERT_ERROR(eq(ev[ 9], 2.8), {}, "cbc", "matrix by row after assignment: elements");
     538      OSIUNITTEST_ASSERT_ERROR(eq(ev[10],-1.2), {}, "cbc", "matrix by row after assignment: elements");
     539      OSIUNITTEST_ASSERT_ERROR(eq(ev[11], 5.6), {}, "cbc", "matrix by row after assignment: elements");
     540      OSIUNITTEST_ASSERT_ERROR(eq(ev[12], 1.0), {}, "cbc", "matrix by row after assignment: elements");
     541      OSIUNITTEST_ASSERT_ERROR(eq(ev[13], 1.9), {}, "cbc", "matrix by row after assignment: elements");
    771542     
    772543      const CoinBigIndex * mi = lhsmbr->getVectorStarts();
    773       assert( mi[0]==0 );
    774       assert( mi[1]==5 );
    775       assert( mi[2]==7 );
    776       assert( mi[3]==9 );
    777       assert( mi[4]==11 );
    778       assert( mi[5]==14 );
     544      OSIUNITTEST_ASSERT_ERROR(mi[0] ==  0, {}, "cbc", "matrix by row after assignment: vector starts");
     545      OSIUNITTEST_ASSERT_ERROR(mi[1] ==  5, {}, "cbc", "matrix by row after assignment: vector starts");
     546      OSIUNITTEST_ASSERT_ERROR(mi[2] ==  7, {}, "cbc", "matrix by row after assignment: vector starts");
     547      OSIUNITTEST_ASSERT_ERROR(mi[3] ==  9, {}, "cbc", "matrix by row after assignment: vector starts");
     548      OSIUNITTEST_ASSERT_ERROR(mi[4] == 11, {}, "cbc", "matrix by row after assignment: vector starts");
     549      OSIUNITTEST_ASSERT_ERROR(mi[5] == 14, {}, "cbc", "matrix by row after assignment: vector starts");
    779550     
    780551      const int * ei = lhsmbr->getIndices();
    781       assert( ei[0]  ==  0 );
    782       assert( ei[1]  ==  1 );
    783       assert( ei[2]  ==  3 );
    784       assert( ei[3]  ==  4 );
    785       assert( ei[4]  ==  7 );
    786       assert( ei[5]  ==  1 );
    787       assert( ei[6]  ==  2 );
    788       assert( ei[7]  ==  2 );
    789       assert( ei[8]  ==  5 );
    790       assert( ei[9]  ==  3 );
    791       assert( ei[10] ==  6 );
    792       assert( ei[11] ==  0 );
    793       assert( ei[12] ==  4 );
    794       assert( ei[13] ==  7 );   
    795 
     552      OSIUNITTEST_ASSERT_ERROR(ei[ 0] == 0, {}, "cbc", "matrix by row after assignment: indices");
     553      OSIUNITTEST_ASSERT_ERROR(ei[ 1] == 1, {}, "cbc", "matrix by row after assignment: indices");
     554      OSIUNITTEST_ASSERT_ERROR(ei[ 2] == 3, {}, "cbc", "matrix by row after assignment: indices");
     555      OSIUNITTEST_ASSERT_ERROR(ei[ 3] == 4, {}, "cbc", "matrix by row after assignment: indices");
     556      OSIUNITTEST_ASSERT_ERROR(ei[ 4] == 7, {}, "cbc", "matrix by row after assignment: indices");
     557      OSIUNITTEST_ASSERT_ERROR(ei[ 5] == 1, {}, "cbc", "matrix by row after assignment: indices");
     558      OSIUNITTEST_ASSERT_ERROR(ei[ 6] == 2, {}, "cbc", "matrix by row after assignment: indices");
     559      OSIUNITTEST_ASSERT_ERROR(ei[ 7] == 2, {}, "cbc", "matrix by row after assignment: indices");
     560      OSIUNITTEST_ASSERT_ERROR(ei[ 8] == 5, {}, "cbc", "matrix by row after assignment: indices");
     561      OSIUNITTEST_ASSERT_ERROR(ei[ 9] == 3, {}, "cbc", "matrix by row after assignment: indices");
     562      OSIUNITTEST_ASSERT_ERROR(ei[10] == 6, {}, "cbc", "matrix by row after assignment: indices");
     563      OSIUNITTEST_ASSERT_ERROR(ei[11] == 0, {}, "cbc", "matrix by row after assignment: indices");
     564      OSIUNITTEST_ASSERT_ERROR(ei[12] == 4, {}, "cbc", "matrix by row after assignment: indices");
     565      OSIUNITTEST_ASSERT_ERROR(ei[13] == 7, {}, "cbc", "matrix by row after assignment: indices");
    796566#else   // OSICBC_TEST_MTX_STRUCTURE
    797567
     
    805575      CoinPackedVector freeRow ;
    806576      exmip1Mtx.appendRow(freeRow) ;
    807       assert( exmip1Mtx.isEquivalent(*lhsmbr) ) ;
    808 
     577      OSIUNITTEST_ASSERT_ERROR(exmip1Mtx.isEquivalent(*lhsmbr), {}, "cbc", "matrix by row after assignment");
    809578#endif  // OSICBC_TEST_MTX_STRUCTURE
    810      
    811       int md = lhsmbr->getMajorDim();
    812       assert(  md == 6 );
    813       assert( lhsmbr->getNumElements() == 14 );
    814     }
    815    
     579    }
    816580  }
    817581
     
    830594    double objValue = m.getObjValue();
    831595    CoinRelFltEq eq(1.0e-2);
    832     assert( eq(objValue,2520.57) );
     596    OSIUNITTEST_ASSERT_ERROR(eq(objValue,2520.57), {}, "cbc", "objvalue after adding col");
     597
    833598    // Try deleting first column that's nonbasic at lower bound (0).
    834599    int * d = new int[1];
    835     CoinWarmStartBasis *cwsb =
    836         dynamic_cast<CoinWarmStartBasis *>(m.getWarmStart()) ;
    837     assert(cwsb) ;
     600    CoinWarmStartBasis *cwsb = dynamic_cast<CoinWarmStartBasis *>(m.getWarmStart()) ;
     601    OSIUNITTEST_ASSERT_ERROR(cwsb != NULL, {}, "cbc", "get warmstart basis");
    838602    CoinWarmStartBasis::Status stati ;
    839603    int iCol ;
     
    848612    m.resolve();
    849613    objValue = m.getObjValue();
    850     assert( eq(objValue,2520.57) );
     614    OSIUNITTEST_ASSERT_ERROR(eq(objValue,2520.57), {}, "clp", "objvalue after deleting first col");
     615
    851616    // Try deleting column we added. If basic, go to initialSolve as deleting
    852617    // basic variable trashes basis required for warm start.
     
    861626    { m.resolve(); }
    862627    objValue = m.getObjValue();
    863     assert( eq(objValue,2520.57) );
    864 
    865   }
    866   // Test matt
    867   if (fopen("../Cbc/matt.mps","r")) {   
    868     OsiCbcSolverInterface m;
    869     m.readMps("../Cbc/matt","mps");
    870     m.setHintParam(OsiDoPresolveInResolve, true, OsiHintDo);
    871     m.resolve();
    872    
    873     std::vector<double *> rays = m.getDualRays(1);
    874     std::cout << "Dual Ray: " << std::endl;
    875     for(int i = 0; i < m.getNumRows(); i++){
    876       if(fabs(rays[0][i]) > 0.00001)
    877         std::cout << i << " : " << rays[0][i] << std::endl;
    878     }
    879    
    880     std::cout << "isProvenOptimal = " << m.isProvenOptimal() << std::endl;
    881     std::cout << "isProvenPrimalInfeasible = " << m.isProvenPrimalInfeasible()
    882          << std::endl;
    883    
    884     delete [] rays[0];
    885    
     628    OSIUNITTEST_ASSERT_ERROR(eq(objValue,2520.57), {}, "clp", "objvalue after deleting added col");
    886629  }
    887630
     
    997740    if (numberColumns<50)
    998741      build.setLogLevel(1);
    999     int numberErrors=model2.loadFromCoinModel(build);
    1000742    // should fail as we never set multiplier
    1001     assert (numberErrors);
     743    OSIUNITTEST_ASSERT_ERROR(model2.loadFromCoinModel(build) != 0, {}, "cbc", "build model with missing multipliers");
    1002744    build.associateElement("multiplier",0.0);
    1003     numberErrors=model2.loadFromCoinModel(build);
    1004     assert (!numberErrors);
     745    OSIUNITTEST_ASSERT_ERROR(model2.loadFromCoinModel(build) == 0, {}, "cbc", "build model");
    1005746    model2.initialSolve();
    1006747    // It then loops with multiplier going from 0.0 to 2.0 in increments of 0.1
    1007748    for (double multiplier=0.0;multiplier<2.0;multiplier+= 0.1) {
    1008749      build.associateElement("multiplier",multiplier);
    1009       numberErrors=model2.loadFromCoinModel(build,true);
    1010       assert (!numberErrors);
     750      OSIUNITTEST_ASSERT_ERROR(model2.loadFromCoinModel(build,true) == 0, {}, "cbc", "build model with increasing multiplier");
    1011751      model2.resolve();
    1012752    }
    1013753  }
     754
    1014755  // branch and bound
    1015756  {   
     
    1022763    m.branchAndBound();
    1023764  }
     765
    1024766  // branch and bound using CbcModel!!!!!!!
    1025767  {   
     
    1031773    m.branchAndBound();
    1032774  }
    1033 #ifdef COIN_HAS_OSL
    1034   // branch and bound using OSL
    1035   {   
    1036     OsiOslSolverInterface mmm;
    1037     OsiCbcSolverInterface mm(&mmm);
    1038     CbcStrategyNull strategy;
    1039     OsiCbcSolverInterface m(&mm,&strategy);
    1040     std::string fn = mpsDir+"p0033";
    1041     m.readMps(fn.c_str(),"mps");
    1042     //m.initialSolve();
    1043     m.branchAndBound();
    1044   }
    1045 #endif
    1046   int errCnt = 0;
     775
    1047776  // Do common solverInterface testing
    1048777  {
    1049778    OsiCbcSolverInterface m;
    1050     errCnt += OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
     779    OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
    1051780  }
    1052781  {
    1053782    OsiCbcSolverInterface mm;
    1054783    OsiCbcSolverInterface m(&mm);
    1055     errCnt += OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
     784    OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
    1056785  }
    1057 #ifdef COIN_HAS_OSL
    1058   {
    1059     OsiOslSolverInterface mm;
    1060     OsiCbcSolverInterface m(&mm);
    1061     errCnt += OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
    1062   }
    1063 #endif
    1064   return errCnt;
     786
     787  return 0;
    1065788}
  • trunk/Cbc/test/osiUnitTest.cpp

    r1620 r1666  
    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"
    77
    8 #include "OsiConfig.h"
    9 
    10 #ifdef NDEBUG
    11 #undef NDEBUG
    12 #endif
    13 
    14 #include <cassert>
    158#include <cstdio>
    169#include <iostream>
    17 #include <map>
    1810
    1911#include "OsiUnitTests.hpp"
    2012#include "OsiRowCutDebugger.hpp"
     13#include "OsiRowCut.hpp"
     14#include "OsiColCut.hpp"
    2115
    2216#include "CoinError.hpp"
     
    2418#include "OsiCbcSolverInterface.hpp"
    2519
    26 namespace {
    27 
    28 // Display message on stdout and stderr. Flush cout buffer before printing the
    29 // message, so that output comes out in order in spite of buffered cout.
    30 
    31 void testingMessage( const char * const msg )
    32 {
    33   std::cout.flush() ;
    34   std::cerr <<msg;
    35   //cout <<endl <<"*****************************************"
    36   //     <<endl <<msg <<endl;
    37 }
    38 
    39 
    40 /*
    41   Utility routine to process command line parameters. An unrecognised parameter
    42   will trigger the help message and a return value of false.
    43  
    44   This should be replaced with the one of the standard CoinUtils parameter
    45   mechanisms.
    46 */
    47 bool processParameters (int argc, const char **argv,
    48                         std::map<std::string,std::string> &parms)
    49 
    50 {
    51   assert(argc >= 1);
    52   assert(argv != NULL);
    53 /*
    54   Initialise the parameter keywords.
    55 */
    56   std::set<std::string> definedKeyWords;
    57   definedKeyWords.insert("-cerr2cout");
    58   definedKeyWords.insert("-mpsDir");
    59   definedKeyWords.insert("-netlibDir");
    60   definedKeyWords.insert("-testOsiSolverInterface");
    61   definedKeyWords.insert("-nobuf");
    62 /*
    63   Set default values for data directories.
    64 */
    65   std::string dirsep(1,CoinFindDirSeparator()) ;
    66   std::string upOne = ".."+dirsep ;
    67   std::string pathTmp ;
    68 /*
    69   Establish likely defaults for the Sample and Miplib directories.
    70 */
    71 # ifdef SAMPLEDIR
    72     pathTmp = SAMPLEDIR ;
    73 # else
    74     pathTmp = upOne+upOne+"Data"+dirsep+"Sample" ;
    75 # endif
    76   parms["-mpsDir"] = pathTmp  ;
    77 # ifdef NETLIBDIR
    78     pathTmp = NETLIBDIR ;
    79 # else
    80     pathTmp = upOne+upOne+"Data"+dirsep+"Netlib" ;
    81 # endif
    82   parms["-netlibDir"] = pathTmp ;
    83 /*
    84   Read the command line parameters and fill a map of parameter keys and
    85   associated data. The parser allows for parameters which are only a keyword,
    86   or parameters of the form keyword=value (no spaces).
    87 */
    88   for (int i = 1 ; i < argc ; i++)
    89   { std::string parm(argv[i]) ;
    90     std::string key,value ;
    91     std::string::size_type eqPos = parm.find('=');
    92 
    93     if (eqPos == std::string::npos)
    94     { key = parm ; }
    95     else
    96     { key = parm.substr(0,eqPos) ;
    97       value = parm.substr(eqPos+1) ; }
    98 /*
    99   Is the specifed key valid?
    100 */
    101     if (definedKeyWords.find(key) == definedKeyWords.end())
    102     { std::cerr << "Undefined parameter \"" << key << "\"." << std::endl ;
    103       std::cerr
    104         << "Usage: " << argv[0]
    105         << " [-nobuf] [-mpsDir=V1] [-netlibDir=V2] "
    106         << "[-testOsiSolverInterface] " << std::endl ;
    107       std::cerr << "  where:" << std::endl ;
    108       std::cerr
    109         << "    "
    110         << "-cerr2cout: redirect cerr to cout; sometimes useful." << std::endl
    111         << "\t" << "to synchronise cout & cerr." << std::endl ;
    112       std::cerr
    113         << "    "
    114         << "-mpsDir: directory containing mps test files." << std::endl
    115         << "\t" << "Default value V1=\"../../Data/Sample\"" << std::endl ;
    116       std::cerr
    117         << "    "
    118         << "-netlibDir: directory containing netlib files." << std::endl
    119         << "\t" << "Default value V2=\"../../Data/Netlib\"" << std::endl ;
    120       std::cerr
    121         << "    "
    122         << "-testOsiSolverInterface: "
    123         << "run each OSI on the netlib problem set." << std::endl
    124         << "\t"
    125         << "Default is to not run the netlib problem set." << std::endl ;
    126       std::cerr
    127         << "    "
    128         << "-nobuf: use unbuffered output." << std::endl
    129         << "\t" << "Default is buffered output." << std::endl ;
    130      
    131       return (false) ; }
    132 /*
    133   Valid keyword; stash the value for later reference.
    134 */
    135     parms[key]=value ; }
    136 /*
    137   Tack the directory separator onto the data directories so we don't have to
    138   worry about it later.
    139 */
    140   parms["-mpsDir"] += dirsep ;
    141   parms["-netlibDir"] += dirsep ;
    142 /*
    143   Did the user request unbuffered i/o? It seems we need to go after this
    144   through stdio --- using pubsetbuf(0,0) on the C++ streams has no
    145   discernible affect. Nor, for that matter, did setting the unitbuf flag on
    146   the streams. Why? At a guess, sync_with_stdio connects the streams to the
    147   stdio buffers, and the C++ side isn't programmed to change them?
    148 */
    149   if (parms.find("-nobuf") != parms.end())
    150   { // std::streambuf *coutBuf, *cerrBuf ;
    151     // coutBuf = std::cout.rdbuf() ;
    152     // coutBuf->pubsetbuf(0,0) ;
    153     // cerrBuf = std::cerr.rdbuf() ;
    154     // cerrBuf->pubsetbuf(0,0) ;
    155     setbuf(stderr,0) ;
    156     setbuf(stdout,0) ; }
    157 /*
    158   Did the user request a redirect for cerr? This must occur before any i/o is
    159   performed.
    160 */
    161   if (parms.find("-cerr2cout") != parms.end())
    162   { std::cerr.rdbuf(std::cout.rdbuf()) ; }
    163 
    164   return (true) ; }
    165 
    166 
    167 }       // end file-local namespace
    168 
    169 
     20using namespace OsiUnitTest;
    17021
    17122//----------------------------------------------------------------
    172 // unitTest [-nobuf] [-mpsDir=V1] [-netlibDir=V2] [-testOsiSolverInterface]
    173 //
    174 // where:
    175 //   -nobuf: remove buffering on cout (stdout); useful to keep cout and cerr
    176 //       messages synchronised when redirecting output to a file or pipe.
    177 //   -mpsDir: directory containing mps test files
    178 //       Default value V1="../../Data/Sample"   
    179 //   -netlibDir: directory containing netlib files
    180 //       Default value V2="../../Data/Netlib"
    181 //   -testOsiSolverInterface
    182 //       If specified, then OsiSolveInterface::unitTest
    183 //       is skipped over and not run.
    184 //
    185 // All parameters are optional.
     23// to see parameter list, call unitTest -usage
    18624//----------------------------------------------------------------
    18725
    18826int main (int argc, const char *argv[])
    189 
    190 { int totalErrCnt = 0;
    191 
     27{
    19228/*
    19329  Start off with various bits of initialisation that don't really belong
    19430  anywhere else.
    195 
    196   First off, synchronise C++ stream i/o with C stdio. This makes debugging
     31 */
     32  outcomes.clear();
     33/*
     34  Synchronise C++ stream i/o with C stdio. This makes debugging
    19735  output a bit more comprehensible. It still suffers from interleave of cout
    19836  (stdout) and cerr (stderr), but -nobuf deals with that.
    199 */
     37 */
    20038  std::ios::sync_with_stdio() ;
    20139/*
    20240  Suppress an popup window that Windows shows in response to a crash. See
    20341  note at head of file.
    204 */
     42 */
    20543  WindowsErrorPopupBlocker();
     44
    20645/*
    20746  Process command line parameters.
    208 */
    209   std::map<std::string,std::string> parms ;
    210 
     47 */
     48  std::map<std::string,std::string> parms;
    21149  if (processParameters(argc,argv,parms) == false)
    212   { return (1) ; }
     50    return 1;
    21351
    21452  std::string mpsDir = parms["-mpsDir"] ;
    21553  std::string netlibDir = parms["-netlibDir"] ;
    21654
    217 try {
    218 /*
    219   Test Osi{Row,Col}Cut routines.
    220 */
     55  /*
     56    Test Osi{Row,Col}Cut routines.
     57   */
    22158  {
    22259    OsiCbcSolverInterface cbcSi;
    22360    testingMessage( "Testing OsiRowCut with OsiCbcSolverInterface\n" );
    224     OsiRowCutUnitTest(&cbcSi,mpsDir);
     61    OSIUNITTEST_CATCH_ERROR(OsiRowCutUnitTest(&cbcSi,mpsDir), {}, cbcSi, "rowcut unittest");
    22562  }
    22663  {
    22764    OsiCbcSolverInterface cbcSi;
    22865    testingMessage( "Testing OsiColCut with OsiCbcSolverInterface\n" );
    229     OsiColCutUnitTest(&cbcSi,mpsDir);
     66    OSIUNITTEST_CATCH_ERROR(OsiColCutUnitTest(&cbcSi,mpsDir), {}, cbcSi, "colcut unittest");
    23067  }
    23168  {
    23269    OsiCbcSolverInterface cbcSi;
    23370    testingMessage( "Testing OsiRowCutDebugger with OsiCbcSolverInterface\n" );
    234     OsiRowCutDebuggerUnitTest(&cbcSi,mpsDir);
     71    OSIUNITTEST_CATCH_ERROR(OsiRowCutDebuggerUnitTest(&cbcSi,mpsDir), {}, cbcSi, "rowcut debugger unittest");
    23572  }
    23673
    237 /*
    238   Run the OsiXXX class test. It's up to the OsiCbc implementor
    239   to decide whether or not to run OsiSolverInterfaceCommonUnitTest. Arguably
    240   this should be required.
    241 */
     74  /*
     75    Run the OsiCbc class test. This will also call OsiSolverInterfaceCommonUnitTest.
     76   */
    24277  testingMessage( "Testing OsiCbcSolverInterface\n" );
    243   OsiCbcSolverInterfaceUnitTest(mpsDir,netlibDir);
     78  OSIUNITTEST_CATCH_ERROR(OsiCbcSolverInterfaceUnitTest(mpsDir,netlibDir), {}, "cbc", "osicbc unittest");
    24479
    245 /*
    246   We have run the specialised unit test. Check now to see if we need to
    247   run through the Netlib problems.
    248 */
     80  /*
     81    We have run the specialised unit test.
     82    Check now to see if we need to run through the Netlib problems.
     83   */
    24984  if (parms.find("-testOsiSolverInterface") != parms.end())
    25085  {
     
    25388
    25489    testingMessage( "Testing OsiSolverInterface on Netlib problems.\n" );
    255     OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir);
     90    OSIUNITTEST_CATCH_ERROR(OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir), {}, "cbc", "netlib unittest");
    25691
    25792    delete vecSi[0];
    25893  }
    259   else {
    260     testingMessage( "***Skipped Testing of OsiCbcSolverInterface on Netlib problems***\n" );
    261     testingMessage( "***use -testOsiSolverInterface to run them.***\n" );
    262   }
    263 } catch (CoinError& error) {
     94  else
     95    testingMessage( "***Skipped Testing of OsiCbcSolverInterface on Netlib problems, use -testOsiSolverInterface to run them.***\n" );
     96
     97  /*
     98    We're done. Report on the results.
     99   */
    264100  std::cout.flush();
    265   std::cerr << "Caught CoinError exception: ";
    266   error.print(true);
    267   totalErrCnt += 1;
     101  outcomes.print();
     102
     103  int nerrors;
     104  int nerrors_expected;
     105  outcomes.getCountBySeverity(TestOutcome::ERROR, nerrors, nerrors_expected);
     106
     107  if (nerrors > nerrors_expected)
     108    std::cerr << "Tests completed with " << nerrors - nerrors_expected << " unexpected errors." << std::endl ;
     109  else
     110    std::cerr << "All tests completed successfully\n";
     111
     112  return nerrors - nerrors_expected;
    268113}
    269 /*
    270   We're done. Report on the results.
    271 */
    272   if (totalErrCnt)
    273   { std::cout.flush() ;
    274     std::cerr
    275       << "Tests completed with " << totalErrCnt << " errors." << std::endl ;
    276   } else
    277   { testingMessage("All tests completed successfully\n") ; }
    278   return totalErrCnt;
    279 }
Note: See TracChangeset for help on using the changeset viewer.