diff -r b873350e6258 -r 8d281761dea4 test/lp_test.cc --- a/test/lp_test.cc Thu Jan 19 15:25:06 2012 +0100 +++ b/test/lp_test.cc Sat May 05 10:22:44 2012 +0200 @@ -41,11 +41,38 @@ using namespace lemon; +int countCols(LpBase & lp) { + int count=0; + for (LpBase::ColIt c(lp); c!=INVALID; ++c) ++count; + return count; +} + +int countRows(LpBase & lp) { + int count=0; + for (LpBase::RowIt r(lp); r!=INVALID; ++r) ++count; + return count; +} + + void lpTest(LpSolver& lp) { typedef LpSolver LP; + // Test LpBase::clear() + check(countRows(lp)==0, "Wrong number of rows"); + check(countCols(lp)==0, "Wrong number of cols"); + lp.addCol(); lp.addRow(); lp.addRow(); + check(countRows(lp)==2, "Wrong number of rows"); + check(countCols(lp)==1, "Wrong number of cols"); + lp.clear(); + check(countRows(lp)==0, "Wrong number of rows"); + check(countCols(lp)==0, "Wrong number of cols"); + lp.addCol(); lp.addCol(); lp.addCol(); lp.addRow(); + check(countRows(lp)==1, "Wrong number of rows"); + check(countCols(lp)==3, "Wrong number of cols"); + lp.clear(); + std::vector x(10); // for(int i=0;i<10;i++) x.push_back(lp.addCol()); lp.addColSet(x);