Writing Unit tests

Additional asserts.

Literally compare files, line by line: TS_ASSERT_FILE_EQ. This assert will pass if files are equal and generate unit test error otherwise. Example:

#include <cxxtest/TestSuite.h>
...
TS_ASSERT_FILE_EQ( "original.pdb" , "new.pdb" ); // will generate error if files are different

Compare files as a string of double numbers: TS_ASSERT_FILE_EQ_AS_DOUBLE. This command read two text file convert them to a vector of doubles (using space as separator) and compare vector of doubles using specified absolute and relative tolerance. Example:

#include <cxxtest/TestSuite.h>
...
// comparing files "original_score.txt" and "new_score.txt" as vectors of double with abs. tolerance .001 and relative tolerance .1
TS_ASSERT_FILE_EQ_AS_DOUBLE( "original_score.txt" , "new_score.txt" ,
                             .001, // absolute tolerance
                             .1); // relative tolerance

Additional functions.

inline void core_init\_with_additional_options( std::string const & commandline_in )

Reinitialize option system in middle of the test with additional arguments. Actual command line that will be used is equal original command line (which was supplied to unit test executable) + new arguments supplied to the function.

Please note that this function do not delete any singletons that already was allocated (for example ResidueSet). If you need to re-initialize such singleton - delete them by hand before calling this function.

#include <test/core/init_util.hh>
...
// calling core::init with a new command line = old cm.line + "-score_only -out:file:fullatom"
core_init_with_additional_options( "-score_only -out:file:fullatom" );