source: trunk/Cbc/test/osiUnitTest.cpp @ 1666

Last change on this file since 1666 was 1666, checked in by stefan, 10 years ago

use new osi unittest macros and functions in osicbc test

File size: 3.4 KB
Line 
1// Copyright (C) 2000, International Business Machines
2// Corporation and others.  All Rights Reserved.
3// This code is licensed under the terms of the Eclipse Public License (EPL).
4// $Id$
5
6#include "CoinPragma.hpp"
7
8#include <cstdio>
9#include <iostream>
10
11#include "OsiUnitTests.hpp"
12#include "OsiRowCutDebugger.hpp"
13#include "OsiRowCut.hpp"
14#include "OsiColCut.hpp"
15
16#include "CoinError.hpp"
17
18#include "OsiCbcSolverInterface.hpp"
19
20using namespace OsiUnitTest;
21
22//----------------------------------------------------------------
23// to see parameter list, call unitTest -usage
24//----------------------------------------------------------------
25
26int main (int argc, const char *argv[])
27{
28/*
29  Start off with various bits of initialisation that don't really belong
30  anywhere else.
31 */
32  outcomes.clear();
33/*
34  Synchronise C++ stream i/o with C stdio. This makes debugging
35  output a bit more comprehensible. It still suffers from interleave of cout
36  (stdout) and cerr (stderr), but -nobuf deals with that.
37 */
38  std::ios::sync_with_stdio() ;
39/*
40  Suppress an popup window that Windows shows in response to a crash. See
41  note at head of file.
42 */
43  WindowsErrorPopupBlocker();
44
45/*
46  Process command line parameters.
47 */
48  std::map<std::string,std::string> parms;
49  if (processParameters(argc,argv,parms) == false)
50    return 1;
51
52  std::string mpsDir = parms["-mpsDir"] ;
53  std::string netlibDir = parms["-netlibDir"] ;
54
55  /*
56    Test Osi{Row,Col}Cut routines.
57   */
58  {
59    OsiCbcSolverInterface cbcSi;
60    testingMessage( "Testing OsiRowCut with OsiCbcSolverInterface\n" );
61    OSIUNITTEST_CATCH_ERROR(OsiRowCutUnitTest(&cbcSi,mpsDir), {}, cbcSi, "rowcut unittest");
62  }
63  {
64    OsiCbcSolverInterface cbcSi;
65    testingMessage( "Testing OsiColCut with OsiCbcSolverInterface\n" );
66    OSIUNITTEST_CATCH_ERROR(OsiColCutUnitTest(&cbcSi,mpsDir), {}, cbcSi, "colcut unittest");
67  }
68  {
69    OsiCbcSolverInterface cbcSi;
70    testingMessage( "Testing OsiRowCutDebugger with OsiCbcSolverInterface\n" );
71    OSIUNITTEST_CATCH_ERROR(OsiRowCutDebuggerUnitTest(&cbcSi,mpsDir), {}, cbcSi, "rowcut debugger unittest");
72  }
73
74  /*
75    Run the OsiCbc class test. This will also call OsiSolverInterfaceCommonUnitTest.
76   */
77  testingMessage( "Testing OsiCbcSolverInterface\n" );
78  OSIUNITTEST_CATCH_ERROR(OsiCbcSolverInterfaceUnitTest(mpsDir,netlibDir), {}, "cbc", "osicbc unittest");
79
80  /*
81    We have run the specialised unit test.
82    Check now to see if we need to run through the Netlib problems.
83   */
84  if (parms.find("-testOsiSolverInterface") != parms.end())
85  {
86    // Create vector of solver interfaces
87    std::vector<OsiSolverInterface*> vecSi(1, new OsiCbcSolverInterface);
88
89    testingMessage( "Testing OsiSolverInterface on Netlib problems.\n" );
90    OSIUNITTEST_CATCH_ERROR(OsiSolverInterfaceMpsUnitTest(vecSi,netlibDir), {}, "cbc", "netlib unittest");
91
92    delete vecSi[0];
93  }
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   */
100  std::cout.flush();
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;
113}
Note: See TracBrowser for help on using the repository browser.