IMP logo
IMP Manual  for IMP version 2.6.1
testing.md
1 Debugging and testing your code {#testing}
2 ===============================
3 
4 Ensuring that your code is correct can be very difficult, so %IMP
5 provides a number of tools to help you out.
6 
7 The first set are assert-style macros to use in the C++ code:
8 
9 - IMP_USAGE_CHECK() which should be used to check that arguments to
10  functions and methods satisfy the preconditions.
11 
12 - IMP_INTERNAL_CHECK() which should be used to verify internal state
13  and return values to make sure they satisfy pre and post-conditions.
14 
15 See the [checks](../ref/exception_8h.html) page for more details. As a
16 general guideline, any improper usage should produce at least a warning
17 and all return values should be checked by such code.
18 
19 The second is logging macros such as:
20 
21 - IMP_LOG() which allows controlled display of messages about what the
22  code is doing. See [logging](../ref/log_8h.html) for more information.
23 
24 Finally, each module has a set of unit tests. The
25 tests are located in the `modules/modulename/test` directory.
26 These tests should try, as much as possible, to provide independent
27 verification of the correctness of the code. Any
28 file in that directory or a subdirectory whose name matches `test_*.{py,cpp}`,
29 `medium_test_*.{py,cpp}` or `expensive_test_*.{py,cpp}` is considered a test.
30 Normal tests should run in at most a few seconds on a typical machine, medium
31 tests in 10 seconds or so and expensive tests in a couple of minutes.
32 
33 Some tests will require input files or temporary files. Input files
34 should be placed in a directory called `input` in the `test`
35 directory. The test script should then call
36 \command{self.get_input_file_name(file_name)} to get the true path to
37 the file. Likewise, appropriate names for temporary files should be
38 found by calling
39 \command{self.get_tmp_file_name(file_name)}. Temporary files will be
40 located in `build/tmp.` The test should remove temporary files after
41 using them.
#define IMP_USAGE_CHECK(expr, message)