lp_test: error messages with appropriate status/value info
authorathos
Thu, 07 Jul 2005 15:58:19 +0000
changeset 1543a88ccf686a61
parent 1542 0219ee65ffcc
child 1544 955e8e83f6b1
lp_test: error messages with appropriate status/value info
test/lp_test.cc
     1.1 --- a/test/lp_test.cc	Thu Jul 07 15:00:04 2005 +0000
     1.2 +++ b/test/lp_test.cc	Thu Jul 07 15:58:19 2005 +0000
     1.3 @@ -1,4 +1,5 @@
     1.4 -#include<lemon/lp_skeleton.h>
     1.5 +#include <sstream>
     1.6 +#include <lemon/lp_skeleton.h>
     1.7  #include "test_tools.h"
     1.8  
     1.9  
    1.10 @@ -184,16 +185,20 @@
    1.11  }
    1.12  
    1.13  void solveAndCheck(LpSolverBase& lp, LpSolverBase::SolutionStatus stat, 
    1.14 -		   double exp_opt){
    1.15 +		   double exp_opt) {
    1.16 +  using std::string;
    1.17    lp.solve();
    1.18    //int decimal,sign;
    1.19 -  std::string buf1;
    1.20 +  std::ostringstream buf;
    1.21 +  buf << "Primalstatus should be: " << int(stat);
    1.22 +
    1.23    //  itoa(stat,buf1, 10);
    1.24 -  check(lp.primalStatus()==stat,"Primalstatus should be "+buf1);
    1.25 -    
    1.26 -  if (stat ==  LpSolverBase::OPTIMAL){
    1.27 -    check(std::abs(lp.primalValue()-exp_opt)<1e-3,
    1.28 -	  "Wrong optimal value: the right optimum is ");
    1.29 +  check(lp.primalStatus()==stat, buf.str());
    1.30 +
    1.31 +  if (stat ==  LpSolverBase::OPTIMAL) {
    1.32 +    std::ostringstream buf;
    1.33 +    buf << "Wrong optimal value: the right optimum is " << exp_opt; 
    1.34 +    check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());
    1.35      //+ecvt(exp_opt,2)
    1.36    }
    1.37  }