Factorize code for tests.

cc @thomas-moulard 

Several solvers (e.g. NLopt) can find the expected solution while giving a warning (e.g. the reason why the solver stopped). I thought that since all that matters is the result, I added support for `SOLVER_VALUE_WARNINGS` and factorized things a bit. Tolerances for `f0`, `x` and `f` have to be set at the beginning of the test function.

I also added `BOOST_CHECK_SMALL_OR_CLOSE` because I had a test failing when the solver returned `1e-26` and `0.` was expected. I based it on [this SO question](http://stackoverflow.com/questions/1093453/difference-between-boost-check-close-and-boost-check-close-fraction), but it is certainly improvable.