A little test was born for Expr::simplify().
1.1 --- a/test/lp_test.cc Thu Oct 26 14:20:17 2006 +0000
1.2 +++ b/test/lp_test.cc Fri Oct 27 12:39:13 2006 +0000
1.3 @@ -19,7 +19,7 @@
1.4 #include <sstream>
1.5 #include <lemon/lp_skeleton.h>
1.6 #include "test_tools.h"
1.7 -
1.8 +#include <lemon/tolerance.h>
1.9
1.10 #ifdef HAVE_CONFIG_H
1.11 #include <config.h>
1.12 @@ -175,6 +175,37 @@
1.13 lp.addRow(x[1]+x[3]<=x[5]-3);
1.14 lp.addRow(-7<=x[1]+x[3]-12<=3);
1.15 lp.addRow(x[1]<=x[5]);
1.16 +
1.17 + std::ostringstream buf;
1.18 +
1.19 +
1.20 + //Checking the simplify function
1.21 +
1.22 +// //How to check the simplify function? A map gives no information
1.23 +// //on the question whether a given key is or is not stored in it, or
1.24 +// //it does?
1.25 +// Yes, it does, using the find() function.
1.26 + e=((p1+p2)+(p1-p2));
1.27 + e.simplify();
1.28 + buf << "Coeff. of p2 should be 0";
1.29 + // std::cout<<e[p1]<<e[p2]<<e[p3]<<std::endl;
1.30 + check(e.find(p2)==e.end(), buf.str());
1.31 +
1.32 +
1.33 +
1.34 +
1.35 + e=((p1+p2)+(p1-0.99*p2));
1.36 + double tolerance=0.001;
1.37 + e.simplify(tolerance);
1.38 + buf << "Coeff. of p2 should be 0.01";
1.39 + check(e[p2]>0, buf.str());
1.40 +
1.41 + tolerance=0.02;
1.42 + e.simplify(tolerance);
1.43 + buf << "Coeff. of p2 should be 0";
1.44 + check(e.find(p2)==e.end(), buf.str());
1.45 +
1.46 +
1.47 }
1.48
1.49 {