00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_CONCEPT_CLASSTEST_H
00036 #define OPENMS_CONCEPT_CLASSTEST_H
00037
00038
00039
00040
00041
00042 #include <OpenMS/CONCEPT/Types.h>
00043 #include <OpenMS/CONCEPT/Exception.h>
00044 #include <OpenMS/CONCEPT/UniqueIdGenerator.h>
00045 #include <OpenMS/SYSTEM/File.h>
00046
00047 #include <vector>
00048 #include <string>
00049 #include <cstring>
00050 #include <list>
00051 #include <iostream>
00052 #include <fstream>
00053 #include <boost/lexical_cast.hpp>
00054
00055 #ifdef OPENMS_HAS_UNISTD_H
00056 #include <unistd.h>
00057 #endif
00058
00059 #include <cstdio>
00060 #include <cmath>
00061 #include <cstdlib>
00062
00063
00064
00065
00067 #ifndef std__cout
00068 #define std__cout std::cout
00069 #endif
00070
00071 namespace OpenMS
00072 {
00073 namespace Internal
00074 {
00076 namespace ClassTest
00077 {
00078
00083 bool OPENMS_DLLAPI
00084 validate(const std::vector<std::string>& file_names);
00085
00087 std::string OPENMS_DLLAPI
00088 tmpFileName(const std::string& file, int line);
00089
00091 inline bool OPENMS_DLLAPI
00092 isRealType(float)
00093 {
00094 return true;
00095 }
00096
00098 inline bool OPENMS_DLLAPI
00099 isRealType(double)
00100 {
00101 return true;
00102 }
00103
00105 inline bool OPENMS_DLLAPI
00106 isRealType(long double)
00107 {
00108 return true;
00109 }
00110
00112 inline bool OPENMS_DLLAPI
00113 isRealType(const DataValue&)
00114 {
00115 return true;
00116 }
00117
00119 template <typename T>
00120 inline bool
00121 isRealType(const T&)
00122 {
00123 return false;
00124 }
00125
00131 void OPENMS_DLLAPI
00132 testRealSimilar(const char* file, int line, long double number_1,
00133 const char* number_1_stringified,
00134 bool number_1_is_realtype, Int number_1_written_digits,
00135 long double number_2, const char* number_2_stringified,
00136 bool , Int number_2_written_digits);
00137
00139 bool OPENMS_DLLAPI
00140 isRealSimilar(long double number_1, long double number_2);
00141
00149 void OPENMS_DLLAPI
00150 testStringSimilar(const char* file, int line,
00151 const std::string& string_1,
00152 const char* string_1_stringified,
00153 const std::string& string_2,
00154 const char* string_2_stringified);
00155
00157 void OPENMS_DLLAPI
00158 testStringEqual(const char* file, int line,
00159 const std::string& string_1,
00160 const char* string_1_stringified,
00161 const std::string& string_2,
00162 const char* string_2_stringified);
00163
00169 bool OPENMS_DLLAPI
00170 isFileSimilar(const std::string& filename_1,
00171 const std::string& filename_2);
00172
00174 void OPENMS_DLLAPI
00175 initialNewline();
00176
00178 void OPENMS_DLLAPI
00179 printWithPrefix(const std::string& text, const int marked = -1);
00180
00182 void OPENMS_DLLAPI
00183 setWhitelist(const char* const , const int line,
00184 const std::string& whitelist);
00185
00187 extern OPENMS_DLLAPI double ratio_max_allowed;
00188
00190 extern OPENMS_DLLAPI double ratio_max;
00191
00193 extern OPENMS_DLLAPI double ratio;
00194
00196 extern OPENMS_DLLAPI double absdiff_max_allowed;
00197
00199 extern OPENMS_DLLAPI double absdiff_max;
00200
00202 extern OPENMS_DLLAPI double absdiff;
00203
00204 extern OPENMS_DLLAPI int line_num_1_max;
00205 extern OPENMS_DLLAPI int line_num_2_max;
00206
00208 extern OPENMS_DLLAPI int verbose;
00209
00211 extern OPENMS_DLLAPI bool all_tests;
00212
00214 extern OPENMS_DLLAPI bool test;
00215
00217 extern OPENMS_DLLAPI bool this_test;
00218
00220 extern OPENMS_DLLAPI int exception;
00221
00223 extern OPENMS_DLLAPI std::string exception_name;
00224
00226 extern OPENMS_DLLAPI std::string exception_message;
00227
00229 extern OPENMS_DLLAPI std::string test_name;
00230
00232 extern OPENMS_DLLAPI int start_section_line;
00233
00235 extern OPENMS_DLLAPI int test_line;
00236
00238 extern OPENMS_DLLAPI const char* version_string;
00239
00241 extern OPENMS_DLLAPI std::vector<std::string> tmp_file_list;
00242
00244 extern OPENMS_DLLAPI std::vector<UInt> failed_lines_list;
00245
00247 extern OPENMS_DLLAPI std::ifstream infile;
00248
00250 extern OPENMS_DLLAPI std::ifstream templatefile;
00251
00253 extern OPENMS_DLLAPI bool equal_files;
00254
00256 extern OPENMS_DLLAPI char line_buffer[65536];
00257
00259 extern OPENMS_DLLAPI int test_count;
00260
00262 extern OPENMS_DLLAPI std::string add_message;
00263
00268 extern OPENMS_DLLAPI std::string fuzzy_message;
00269
00271 extern OPENMS_DLLAPI bool newline;
00272
00273 template <typename T1, typename T2>
00274 void
00275 testEqual(const char* , int line, const T1& expression_1,
00276 const char* expression_1_stringified,
00277 const T2& expression_2,
00278 const char* expression_2_stringified)
00279 {
00280 ++test_count;
00281 test_line = line;
00282 this_test = bool(expression_1 == T1(expression_2));
00283 test = test && this_test;
00284 {
00285 initialNewline();
00286 if (this_test)
00287 {
00288 std__cout << " + line " << line << ": TEST_EQUAL("
00289 << expression_1_stringified << ','
00290 << expression_2_stringified << "): got " << expression_1
00291 << ", expected " << expression_2 << std::endl;
00292 }
00293 else
00294 {
00295 std__cout << " - line " << line << ": TEST_EQUAL("
00296 << expression_1_stringified << ','
00297 << expression_2_stringified << "): got " << expression_1
00298 << ", expected " << expression_2 << std::endl;
00299 failed_lines_list.push_back(line);
00300 }
00301 }
00302 }
00303
00304 template <typename T1, typename T2>
00305 void
00306 testNotEqual(const char* , int line, const T1& expression_1,
00307 const char* expression_1_stringified,
00308 const T2& expression_2,
00309 const char* expression_2_stringified)
00310 {
00311 ++test_count;
00312 test_line = line;
00313 this_test = !(expression_1 == T1(expression_2));
00314 test = test && this_test;
00315 {
00316 initialNewline();
00317 if (this_test)
00318 {
00319 std__cout << " + line " << line << ": TEST_NOT_EQUAL("
00320 << expression_1_stringified << ','
00321 << expression_2_stringified << "): got " << expression_1
00322 << ", forbidden is " << expression_2 << std::endl;
00323 }
00324 else
00325 {
00326 std__cout << " - line " << line << ": TEST_NOT_EQUAL("
00327 << expression_1_stringified << ','
00328 << expression_2_stringified << "): got " << expression_1
00329 << ", forbidden is " << expression_2 << std::endl;
00330 failed_lines_list.push_back(line);
00331 }
00332 }
00333 }
00334
00335 }
00336 }
00337 }
00338
00339
00340 namespace TEST = OpenMS::Internal::ClassTest;
00341
00366
00367
00369
00395 #define START_TEST(class_name, version) \
00396 int main(int argc, char** argv) \
00397 { \
00398 \
00399 { \
00400 \
00401 OpenMS::DateTime date_time; \
00402 date_time.set("1999-12-31 23:59:59"); \
00403 OpenMS::UniqueIdGenerator::setSeed(date_time); \
00404 } \
00405 \
00406 TEST::version_string = version; \
00407 \
00408 if (argc > 1) \
00409 { \
00410 std::cerr \
00411 << "This is " << argv[0] << ", the test program for the\n" \
00412 << # class_name " class.\n" \
00413 "\n" \
00414 "On successful operation it returns PASSED,\n" \
00415 "otherwise FAILED is printed.\n"; \
00416 return 1; \
00417 } \
00418 \
00419 try {
00420
00432 #define END_TEST \
00433 \
00434 } \
00435 catch (::OpenMS::Exception::BaseException& e) \
00436 { \
00437 TEST::this_test = false; \
00438 TEST::test = false; \
00439 TEST::all_tests = false; \
00440 { \
00441 TEST::initialNewline(); \
00442 std__cout << "Error: Caught unexpected OpenMS exception of type '" \
00443 << e.getName() \
00444 << "'"; \
00445 if ((e.getLine() > 0) && (std::strcmp(e.getFile(), "") != 0)) \
00446 { \
00447 std__cout << " thrown in line " << e.getLine() << " of file '" << e.getFile() \
00448 << "' in function '" << e.getFunction() << "'"; \
00449 } \
00450 std__cout << " - Message: " << e.what() << std::endl; \
00451 } \
00452 } \
00453 \
00454 catch (std::exception& e) \
00455 { \
00456 TEST::this_test = false; \
00457 TEST::test = false; \
00458 TEST::all_tests = false; \
00459 { \
00460 TEST::initialNewline(); \
00461 std__cout << "Error: Caught unexpected std::exception" << std::endl; \
00462 std__cout << " - Message: " << e.what() << std::endl; \
00463 } \
00464 } \
00465 \
00466 catch (...) \
00467 { \
00468 TEST::this_test = false; \
00469 TEST::test = false; \
00470 TEST::all_tests = false; \
00471 { \
00472 TEST::initialNewline(); \
00473 std__cout << "Error: Caught unidentified and unexpected exception - No message." \
00474 << std::endl; \
00475 } \
00476 } \
00477 \
00478 if (!TEST::validate(TEST::tmp_file_list)) \
00479 { \
00480 TEST::all_tests = false; \
00481 } \
00482 \
00483 if (!TEST::all_tests) \
00484 { \
00485 std__cout << "FAILED" << std::endl; \
00486 if (TEST::add_message != "") std__cout << "Message: " \
00487 << TEST::add_message \
00488 << std::endl; \
00489 std__cout << "Failed lines: "; \
00490 for (OpenMS::Size i = 0; i < TEST::failed_lines_list.size(); ++i) \
00491 { \
00492 std__cout << TEST::failed_lines_list[i] << " "; \
00493 } \
00494 std__cout << std::endl; \
00495 return 1; \
00496 } \
00497 else \
00498 { \
00499 \
00500 for (OpenMS::Size i = 0; i < TEST::tmp_file_list.size(); ++i) \
00501 { \
00502 if (!OpenMS::File::remove(TEST::tmp_file_list[i])) \
00503 { \
00504 std__cout << "Warning: unable to remove temporary file '" \
00505 << TEST::tmp_file_list[i] \
00506 << "'" \
00507 << std::endl; \
00508 } \
00509 } \
00510 std__cout << "PASSED"; \
00511 if (TEST::add_message != "") std__cout << " (" << TEST::add_message << ")"; \
00512 std__cout << std::endl; \
00513 return 0; \
00514 } \
00515 }
00516
00539 #define START_SECTION(name_of_test) \
00540 TEST::test = true; \
00541 TEST::newline = false; \
00542 TEST::test_name = # name_of_test; \
00543 TEST::test_count = 0; \
00544 TEST::start_section_line = __LINE__; \
00545 std__cout << "checking " << TEST::test_name << " ... " << std::flush; \
00546 try \
00547 { \
00548 while (true) \
00549 {
00550
00576 #define END_SECTION \
00577 break; \
00578 } \
00579 } \
00580 catch (::OpenMS::Exception::BaseException& e) \
00581 { \
00582 TEST::this_test = false; \
00583 TEST::test = false; \
00584 TEST::all_tests = false; \
00585 { \
00586 TEST::initialNewline(); \
00587 std__cout << "Error: Caught unexpected exception of type '" << e.getName() << "'"; \
00588 if ((e.getLine() > 0) && (std::strcmp(e.getFile(), "") != 0)) \
00589 { \
00590 std__cout << " thrown in line " << e.getLine() << " of file '" << e.getFile() \
00591 << "' in function '" << e.getFunction() << "'"; \
00592 } \
00593 std__cout << " - Message: " << e.what() << std::endl; \
00594 } \
00595 } \
00596 \
00597 catch (std::exception& e) \
00598 { \
00599 TEST::this_test = false; \
00600 TEST::test = false; \
00601 TEST::all_tests = false; \
00602 { \
00603 TEST::initialNewline(); \
00604 std__cout << "Error: Caught std::exception" << std::endl; \
00605 std__cout << " - Message: " << e.what() << std::endl; \
00606 } \
00607 } \
00608 \
00609 catch (...) \
00610 { \
00611 TEST::this_test = false; \
00612 TEST::test = false; \
00613 TEST::all_tests = false; \
00614 { \
00615 TEST::initialNewline(); \
00616 std__cout << "Error: Caught unidentified and unexpected exception - No message." \
00617 << std::endl; \
00618 } \
00619 } \
00620 TEST::all_tests = TEST::all_tests && TEST::test; \
00621 { \
00622 if (TEST::test) \
00623 { \
00624 std__cout << ": passed" << std::endl; \
00625 } \
00626 else \
00627 { \
00628 std__cout << ": failed" << std::endl; \
00629 } \
00630 } \
00631 \
00632 if (TEST::test_count == 0) \
00633 { \
00634 bool destructor = false; \
00635 for (OpenMS::Size i = 0; i != TEST::test_name.size(); ++i) \
00636 { \
00637 if (TEST::test_name[i] == '~') \
00638 { \
00639 destructor = true; \
00640 break; \
00641 } \
00642 } \
00643 if (!destructor) std__cout << "Warning: no subtests performed in '" \
00644 << TEST::test_name \
00645 << "' (line " \
00646 << __LINE__ \
00647 << ")!" \
00648 << std::endl \
00649 << std::flush; \
00650 } \
00651 std__cout << std::endl;
00652
00654
00674 #define TEST_EQUAL(a, b) TEST::testEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
00675
00687 #define TEST_NOT_EQUAL(a, b) TEST::testNotEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
00688
00701 #define TEST_STRING_EQUAL(a, b) TEST::testStringEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
00702
00717 #define TEST_FILE_EQUAL(filename, templatename) \
00718 { \
00719 ++TEST::test_count; \
00720 TEST::equal_files = true; \
00721 TEST::infile.open(filename, std::ios::in); \
00722 TEST::templatefile.open(templatename, std::ios::in); \
00723 \
00724 if (TEST::infile.good() && TEST::templatefile.good()) \
00725 { \
00726 std::string TEST_FILE__template_line; \
00727 std::string TEST_FILE__line; \
00728 \
00729 while (TEST::infile.good() && TEST::templatefile.good()) \
00730 { \
00731 TEST::templatefile.getline(TEST::line_buffer, 65535); \
00732 TEST_FILE__template_line = TEST::line_buffer; \
00733 TEST::infile.getline(TEST::line_buffer, 65535); \
00734 TEST_FILE__line = TEST::line_buffer; \
00735 \
00736 TEST::equal_files &= (TEST_FILE__template_line == TEST_FILE__line); \
00737 if (TEST_FILE__template_line != TEST_FILE__line) \
00738 { \
00739 { \
00740 TEST::initialNewline(); \
00741 std__cout << " TEST_FILE_EQUAL: line mismatch:\n got: '" \
00742 << TEST_FILE__line << "'\n expected: '" \
00743 << TEST_FILE__template_line << "'" << std::endl; \
00744 } \
00745 } \
00746 } \
00747 } \
00748 else \
00749 { \
00750 TEST::equal_files = false; \
00751 { \
00752 TEST::initialNewline(); \
00753 std__cout << " + line " \
00754 << __LINE__ \
00755 << ": TEST_FILE_EQUAL(" \
00756 << # filename \
00757 << ", " \
00758 << # templatename; \
00759 std__cout << ") : " << " cannot open file: \""; \
00760 if (!TEST::infile.good()) \
00761 { \
00762 std__cout << filename << "\" (input file) "; \
00763 } \
00764 if (!TEST::templatefile.good()) \
00765 { \
00766 std__cout << templatename << "\" (template file) "; \
00767 } \
00768 std__cout << std::endl; \
00769 \
00770 } \
00771 } \
00772 TEST::infile.close(); \
00773 TEST::templatefile.close(); \
00774 TEST::infile.clear(); \
00775 TEST::templatefile.clear(); \
00776 \
00777 TEST::this_test = TEST::equal_files; \
00778 TEST::test = TEST::test && TEST::this_test; \
00779 { \
00780 TEST::initialNewline(); \
00781 if (TEST::this_test) \
00782 { \
00783 std__cout << " + line " \
00784 << __LINE__ \
00785 << ": TEST_FILE_EQUAL(" \
00786 << # filename \
00787 << ", " \
00788 << # templatename \
00789 << "): true"; \
00790 } \
00791 else \
00792 { \
00793 std__cout << " - line " \
00794 << __LINE__ \
00795 << ": TEST_FILE_EQUAL(" \
00796 << # filename \
00797 << ", " \
00798 << # templatename \
00799 << "): false (different files: " \
00800 << filename \
00801 << " " \
00802 << templatename \
00803 << " )\n"; \
00804 TEST::failed_lines_list.push_back(TEST::test_line); \
00805 } \
00806 } \
00807 }
00808
00824 #define TEST_REAL_SIMILAR(a, b) TEST::testRealSimilar(__FILE__, __LINE__, (a), (# a), TEST::isRealType(a), writtenDigits(a), (b), (# b), TEST::isRealType(b), writtenDigits(b));
00825
00841 #define TEST_STRING_SIMILAR(a, b) TEST::testStringSimilar(__FILE__, __LINE__, (a), (# a), (b), (# b));
00842
00857 #define TEST_FILE_SIMILAR(a, b) \
00858 { \
00859 ++TEST::test_count; \
00860 TEST::test_line = __LINE__; \
00861 TEST::this_test = TEST::isFileSimilar((a), (b)); \
00862 TEST::test = TEST::test && TEST::this_test; \
00863 { \
00864 TEST::initialNewline(); \
00865 if (TEST::this_test) \
00866 { \
00867 std__cout << " + line " << __LINE__ \
00868 << ": TEST_FILE_SIMILAR(" # a "," # b "): absolute: " \
00869 << precisionWrapper(TEST::absdiff) \
00870 << " (" \
00871 << precisionWrapper(TEST::absdiff_max_allowed) \
00872 << "), relative: " \
00873 << precisionWrapper(TEST::ratio) \
00874 << " (" \
00875 << precisionWrapper(TEST::ratio_max_allowed) \
00876 << ")" \
00877 << std::endl; \
00878 std__cout << "message: \n"; \
00879 std__cout << TEST::fuzzy_message; \
00880 } \
00881 else \
00882 { \
00883 std__cout << " - line " << TEST::test_line << \
00884 ": TEST_FILE_SIMILAR(" # a "," # b ") ... -\n"; \
00885 std__cout << "message: \n"; \
00886 std__cout << TEST::fuzzy_message; \
00887 TEST::failed_lines_list.push_back(TEST::test_line); \
00888 } \
00889 } \
00890 }
00891
00904 #define TOLERANCE_RELATIVE(a) \
00905 TEST::ratio_max_allowed = (a); \
00906 { \
00907 TEST::initialNewline(); \
00908 std__cout << " + line " << __LINE__ << \
00909 ": TOLERANCE_RELATIVE(" << TEST::ratio_max_allowed << \
00910 ") (\"" # a "\")" << std::endl; \
00911 }
00912
00924 #define TOLERANCE_ABSOLUTE(a) \
00925 TEST::absdiff_max_allowed = (a); \
00926 { \
00927 TEST::initialNewline(); \
00928 std__cout << " + line " << __LINE__ << \
00929 ": TOLERANCE_ABSOLUTE(" << TEST::absdiff_max_allowed << \
00930 ") (\"" # a "\")" << std::endl; \
00931 }
00932
00938 #define WHITELIST(a) TEST::setWhitelist(__FILE__, __LINE__, (a));
00939
00952 #define TEST_EXCEPTION(exception_type, command) \
00953 { \
00954 ++TEST::test_count; \
00955 TEST::test_line = __LINE__; \
00956 TEST::exception = 0; \
00957 try \
00958 { \
00959 command; \
00960 } \
00961 catch (exception_type) \
00962 { \
00963 TEST::exception = 1; \
00964 } \
00965 catch (::OpenMS::Exception::BaseException e) \
00966 { \
00967 TEST::exception = 2; \
00968 TEST::exception_name = e.getName(); \
00969 } \
00970 catch (...) \
00971 { \
00972 TEST::exception = 3; \
00973 } \
00974 TEST::this_test = (TEST::exception == 1); \
00975 TEST::test = TEST::test && TEST::this_test; \
00976 \
00977 { \
00978 TEST::initialNewline(); \
00979 switch (TEST::exception) \
00980 { \
00981 case 0: \
00982 std__cout << " - line " << TEST::test_line << \
00983 ": TEST_EXCEPTION(" # exception_type "," # command \
00984 "): no exception thrown!" << std::endl; \
00985 TEST::failed_lines_list.push_back(TEST::test_line); \
00986 break; \
00987 case 1: \
00988 std__cout << " + line " << TEST::test_line << \
00989 ": TEST_EXCEPTION(" # exception_type "," # command \
00990 "): OK" << std::endl; \
00991 break; \
00992 case 2: \
00993 std__cout << " - line " << TEST::test_line << \
00994 ": TEST_EXCEPTION(" # exception_type "," # command \
00995 "): wrong exception thrown! \"" \
00996 << TEST::exception_name << "\"" << std::endl; \
00997 TEST::failed_lines_list.push_back(TEST::test_line); \
00998 break; \
00999 case 3: \
01000 std__cout << " - line " << TEST::test_line << \
01001 ": TEST_EXCEPTION(" # exception_type "," # command \
01002 "): wrong exception thrown!" << std::endl; \
01003 TEST::failed_lines_list.push_back(TEST::test_line); \
01004 break; \
01005 } \
01006 } \
01007 }
01008
01020 #ifdef OPENMS_ASSERTIONS
01021 #define TEST_PRECONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Precondition, command);
01022 #else
01023 #define TEST_PRECONDITION_VIOLATED(command) STATUS("TEST_PRECONDITION_VIOLATED(" # command ") - skipped");
01024 #endif
01025
01037 #ifdef OPENMS_ASSERTIONS
01038 #define TEST_POSTCONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Postcondition, command);
01039 #else
01040 #define TEST_POSTCONDITION_VIOLATED(command) STATUS("TEST_POSTCONDITION_VIOLATED(" # command ") - skipped");
01041 #endif
01042
01043
01060 #define TEST_EXCEPTION_WITH_MESSAGE(exception_type, command, message) \
01061 { \
01062 ++TEST::test_count; \
01063 TEST::test_line = __LINE__; \
01064 TEST::exception = 0; \
01065 try \
01066 { \
01067 command; \
01068 } \
01069 catch (exception_type et) \
01070 { \
01071 if (std::string(et.getMessage()) != std::string(message)) \
01072 { \
01073 TEST::exception = 4; \
01074 TEST::exception_message = et.getMessage(); \
01075 } \
01076 else TEST::exception = 1; \
01077 } \
01078 catch (::OpenMS::Exception::BaseException e) \
01079 { \
01080 TEST::exception = 2; \
01081 TEST::exception_name = e.getName(); \
01082 } \
01083 catch (...) \
01084 { \
01085 TEST::exception = 3; \
01086 } \
01087 TEST::this_test = (TEST::exception == 1); \
01088 TEST::test = TEST::test && TEST::this_test; \
01089 \
01090 { \
01091 TEST::initialNewline(); \
01092 switch (TEST::exception) \
01093 { \
01094 case 0: \
01095 std__cout << " - line " << TEST::test_line << \
01096 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
01097 "): no exception thrown!" << std::endl; \
01098 TEST::failed_lines_list.push_back(TEST::test_line); \
01099 break; \
01100 case 1: \
01101 \
01102 std__cout << " + line " << TEST::test_line << \
01103 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
01104 "): OK" << std::endl; \
01105 break; \
01106 case 2: \
01107 std__cout << " - line " << TEST::test_line << \
01108 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
01109 "): wrong exception thrown! \"" << \
01110 TEST::exception_name << "\"" << std::endl; \
01111 TEST::failed_lines_list.push_back(TEST::test_line); \
01112 break; \
01113 case 3: \
01114 std__cout << " - line " << TEST::test_line << \
01115 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
01116 "): wrong exception thrown!" << std::endl; \
01117 TEST::failed_lines_list.push_back(TEST::test_line); \
01118 break; \
01119 case 4: \
01120 std__cout << " - line " << TEST::test_line << \
01121 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
01122 "): exception has wrong message: got '" << \
01123 TEST::exception_message << \
01124 "', expected '" << \
01125 (message) << \
01126 "'" << std::endl; \
01127 TEST::failed_lines_list.push_back(TEST::test_line); \
01128 break; \
01129 } \
01130 } \
01131 }
01132
01148 #define NEW_TMP_FILE(filename) \
01149 { \
01150 filename = TEST::tmpFileName(__FILE__, __LINE__); \
01151 TEST::tmp_file_list.push_back(filename); \
01152 { \
01153 TEST::initialNewline(); \
01154 std__cout << " creating new temporary filename '" \
01155 << filename \
01156 << "' (line " \
01157 << __LINE__ \
01158 << ")" \
01159 << std::endl; \
01160 } \
01161 }
01162
01170 #define ABORT_IF(condition) \
01171 if (condition) \
01172 { \
01173 { \
01174 TEST::initialNewline(); \
01175 std__cout << " - line " << __LINE__ << \
01176 ": ABORT_IF(" # condition "): TEST ABORTED" << \
01177 std::endl; \
01178 TEST::failed_lines_list.push_back(TEST::test_line); \
01179 } \
01180 break; \
01181 }
01182
01200 #define STATUS(message) \
01201 { \
01202 TEST::initialNewline(); \
01203 std__cout << " line " \
01204 << __LINE__ \
01205 << ": status: " \
01206 << message \
01207 << std::endl; \
01208 }
01209
01219 #define ADD_MESSAGE(message) \
01220 TEST::add_message = message;
01221
01231 #define NOT_TESTABLE \
01232 TEST::test_count = 1;
01233
01235
01236 #endif //OPENMS_CONCEPT_CLASSTEST_H