ClassTest.h File Reference
Macros used by the test programs in the subdirectoryBNPP/source/TEST.
More...
#include <BNPP/config.h>
#include <BNPP/CONCEPT/Exception.h>
#include <string>
#include <list>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <strstream>
Go to the source code of this file.
Namespaces |
|
| namespace | BNPP |
Defines |
|
| #define | PRECISION(a) TEST::precision = (a); |
| Define the precision for floating
point comparisons. |
|
| #define | START_TEST(class_name, version) |
| Create the test header for a certain
class. |
|
| #define | END_TEST |
| Termination of test program.
|
|
| #define | CHECK(test_name) |
| Declare subtest name. |
|
| #define | STATUS(message) |
| Print a status message. |
|
| #define | OK STATUS("ok") |
| Shorthand for
STATUS("ok"). |
|
| #define | RESULT |
| Check subtest result. |
|
| #define | NEW_TMP_FILE(filename) |
| Create a temporary filename.
|
|
| #define | TEST_REAL_EQUAL(a, b) |
| Floating point equality macro.
|
|
| #define | TEST_EQUAL(a, b) |
| Generic equality macro. |
|
| #define | TEST_NOT_EQUAL(a, b) |
| Generic inequality macro. |
|
| #define | TEST_EXCEPTION(exception_type, command) |
| Exception test macro. |
|
| #define | ABORT_IF(condition) if (condition) break; |
| Skip remainder of subtest. |
|
| #define | TEST_FILE(filename, templatename) |
| File comparison macro. |
|
Detailed Description
Macros used by the test programs in the subdirectoryBNPP/source/TEST.
On successful operation the test program will print out the message "PASSED", otherwise "FAILED".
If called with the -v option, the test program prints verbose information about individual tests.
If called with the -V option, the test program prints even more verbose information for every subtest.
The general form of a test program is as follows: (... provide a skeleton file here ...)
Define Documentation
|
|
Value: TEST::test = true;\ TEST::newline = false;\ if (TEST::verbose > 0)\ std::cout << "checking " << #test_name << "... " << std::flush;\ try\ {\ while (true)\ {\ This macro is used to declare the name of a subtest. If you want to check e.g. the setName method of a class, insert a line CHECK(setName) in your test program. If the test program is called in verbose mode, this leads to the name of the subtest being printed on execution. This macro also opens a |
|
|
Value:
filename = tmpnam(0);\
TEST::tmp_file_list.push_back(filename);\
if (TEST::verbose > 1)\
{\
if (!TEST::newline) \
{\
TEST::newline = true;\
std::cout << std::endl;\
}\
std::cout << " creating new temporary file '" << filename << "' (line " << __LINE__ << ")" << std::endl;\
}\
This macro assigns a new temporary filename to the string variable given as its argument. The filename is created using tmpnam. All temporary files are deleted if END_TEST is called.
|
|
|
Value: if (TEST::verbose > 1)\ {\ if (!TEST::newline) \ {\ TEST::newline = true;\ std::cout << std::endl;\ }\ std::cout << " status (line " << __LINE__ << "): " << message << std::endl;\ }\ If tests require longer preparations, STATUS may be used to
print some intermediated progress messages. STATUS uses
Example: |

