Write additional unit tests
awinkler opened this issue · comments
A good way to get familiar with a code-base and understand the functionality is writing some unit tests. These tests would also greatly benefit the library and other users.
We have set-up the infrastructure of unit tests using gtest here:
https://github.com/ethz-adrl/towr/tree/master/towr/test
To write your own test, we would recommend building objects of variables, costs and constraints and ensuring that the GetValues() and other functions return whatever the documentation says. Derivatives, so the GetJacobian() functions don't have to be tested, as this is already provided by Ipopt (see here).
A good practice is too keep unit tests short (<10 lines), and have them include as little other classes as possible. Each test should focus one one single method, queried with a range of possible parameters. An example to folow can be seen here:
https://github.com/ethz-adrl/ifopt/blob/master/ifopt_core/test/composite_test.cc