# OsiUnitTest Namespace Reference

A namespace so we can define a few `global' variables to use during tests. More...

## Classes
class | TestOutcome
| A single test outcome record. More...
class | TestOutcomes
| Utility class to maintain a list of test outcomes. More...
## Functions
void | failureMessage (const std::string &solverName, const std::string &message)
| Print an error message.
void | failureMessage (const OsiSolverInterface &si, const std::string &message)
void | failureMessage (const std::string &solverName, const std::string &testname, const std::string &testcond)
| Print an error message, specifying the test name and condition.
void | failureMessage (const OsiSolverInterface &si, const std::string &testname, const std::string &testcond)
void | testingMessage (const char *const msg)
| Print a message.
bool | equivalentVectors (const OsiSolverInterface *si1, const OsiSolverInterface *si2, double tol, const double *v1, const double *v2, int size)
| Utility method to check equality.
bool | compareProblems (OsiSolverInterface *osi1, OsiSolverInterface *osi2)
| Compare two problems for equality.
bool | isEquivalent (const CoinPackedVectorBase &pv, int n, const double *fv)
| Compare a packed vector with an expanded vector.
bool | processParameters (int argc, const char **argv, std::map< std::string, std::string > &parms, const std::map< std::string, int > &ignorekeywords=std::map< std::string, int >())
| Process command line parameters.
template<typename Component >
bool | OsiUnitTestAssertSeverityExpected (bool condition, const char *condition_str, const char *filename, int line, const Component &component, const std::string &testname, TestOutcome::SeverityLevel severity, bool expected)
## Variables
unsigned int | verbosity
| Verbosity level of unit tests.
unsigned int | haltonerror
| Behaviour on failing a test.
TestOutcomes | outcomes
| Test outcomes.

## Detailed Description

A namespace so we can define a few `global' variables to use during tests.

## Function Documentation

void OsiUnitTest::failureMessage | ( | const std::string & | solverName,
|  | const std::string & | message |
| ) |  |  |

Print an error message.

Formatted as "XxxSolverInterface testing issue: message" where Xxx is the string provided as `solverName`.

Flushes std::cout before printing to std::cerr.

void OsiUnitTest::failureMessage | ( | const OsiSolverInterface & | si,
|  | const std::string & | message |
| ) |  |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void OsiUnitTest::failureMessage | ( | const std::string & | solverName,
|  | const std::string & | testname,
|  | const std::string & | testcond |
| ) |  |  |

Print an error message, specifying the test name and condition.

Formatted as "XxxSolverInterface testing issue: testname failed: testcond" where Xxx is the OsiStrParam::OsiSolverName parameter of the `si`. Flushes std::cout before printing to std::cerr.

void OsiUnitTest::failureMessage | ( | const OsiSolverInterface & | si,
|  | const std::string & | testname,
|  | const std::string & | testcond |
| ) |  |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void OsiUnitTest::testingMessage | ( | const char *const | msg | ) |

Print a message.

Prints the message as given. Flushes std::cout before printing to std::cerr.

bool OsiUnitTest::equivalentVectors | ( | const OsiSolverInterface * | si1,
|  | const OsiSolverInterface * | si2,
|  | double | tol,
|  | const double * | v1,
|  | const double * | v2,
|  | int | size |
| ) |  |  |

Utility method to check equality.

Tests for equality using CoinRelFltEq with tolerance `tol`. Understands the notion of solver infinity and obtains the value for infinity from the solver interfaces supplied as parameters.

bool OsiUnitTest::compareProblems | ( | OsiSolverInterface * | osi1,
|  | OsiSolverInterface * | osi2 |
| ) |  |  |

Compare two problems for equality.

Compares the problems held in the two solvers: constraint matrix, row and column bounds, column type, and objective. Rows are checked using upper and lower bounds and using sense, bound, and range.

bool OsiUnitTest::isEquivalent | ( | const CoinPackedVectorBase & | pv,
|  | int | n,
|  | const double * | fv |
| ) |  |  |

Compare a packed vector with an expanded vector.

Checks that all values present in the packed vector are present in the full vector and checks that there are no extra entries in the full vector. Uses CoinRelFltEq with the default tolerance.

bool OsiUnitTest::processParameters | ( | int | argc,
|  | const char ** | argv,
|  | std::map< std::string, std::string > & | parms,
|  | const std::map< std::string, int > & | ignorekeywords = `std::map< std::string, int >()` |
| ) |  |  |

Process command line parameters.

An unrecognised keyword which is not in the `ignorekeywords` map will trigger the help message and a return value of false. For each keyword in `ignorekeywords`, you can specify the number of following parameters that should be ignored.

This should be replaced with the one of the standard CoinUtils parameter mechanisms.

template<typename Component >

bool OsiUnitTest::OsiUnitTestAssertSeverityExpected | ( | bool | condition,
|  | const char * | condition_str,
|  | const char * | filename,
|  | int | line,
|  | const Component & | component,
|  | const std::string & | testname,
|  | TestOutcome::SeverityLevel | severity,
|  | bool | expected |
| ) |  |  | `[inline]`

Definition at line 236 of file OsiUnitTests.hpp.

## Variable Documentation

unsigned int OsiUnitTest::verbosity

Verbosity level of unit tests.

0 (default) for minimal output; larger numbers produce more output

unsigned int OsiUnitTest::haltonerror

Behaviour on failing a test.

- 0 (= default) continue
- 1 press any key to continue
- 2 stop with abort()

TestOutcomes OsiUnitTest::outcomes

Test outcomes.

A global TestOutcomes object to store test outcomes during the run of the unit test for an OSI.