OpenMS
Loading...
Searching...
No Matches
ClassTest.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm, Clemens Groepl, Chris Bielow, Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11// Avoid OpenMS includes here at all costs
12// When the included headers are changed, *all* tests have to be recompiled!
13// Use the ClassTest class if you need add high-level functionality.
14// Includes in ClassTest.cpp are ok...
17#include <OpenMS/DATASTRUCTURES/StringUtils.h> // for StringUtils::toStr in TEST_EQUAL
20#include <OpenMS/OpenMSConfig.h>
21#include <OpenMS/config.h>
22
23#include <cstring>
24#include <iostream>
25#include <string>
26#include <vector>
27#include <type_traits>
29
30using XMLCh = char16_t; // Xerces-C++ uses char16_t for UTF-16 strings that we need to output in tests
31
32// Empty declaration to avoid problems in case the namespace is not
33// yet defined (e.g. TEST/ClassTest_test.cpp)
34
36#ifndef stdcout
37#define stdcout std::cout
38#endif
39
40namespace OpenMS
41{
42 namespace Internal
43 {
45 namespace ClassTest
46 {
47
52 bool OPENMS_DLLAPI
53 validate(const std::vector<std::string>& file_names);
54
56 std::string OPENMS_DLLAPI
57 createTmpFileName(const std::string& file, int line, const std::string& extension = "");
58
60 inline bool OPENMS_DLLAPI
62 {
63 return true;
64 }
65
67 inline bool OPENMS_DLLAPI
68 isRealType(double)
69 {
70 return true;
71 }
72
74 inline bool OPENMS_DLLAPI
75 isRealType(long double)
76 {
77 return true;
78 }
79
81 inline bool OPENMS_DLLAPI
83 {
84 return true;
85 }
86
88 inline bool OPENMS_DLLAPI
90 {
91 return true;
92 }
93
95 template <typename T>
96 inline bool
97 isRealType(const T&)
98 {
99 return false;
100 }
101
107 void OPENMS_DLLAPI
108 testRealSimilar(const char* file, int line, long double number_1,
109 const char* number_1_stringified,
110 bool number_1_is_realtype, Int number_1_written_digits,
111 long double number_2, const char* number_2_stringified,
112 bool /* number_2_is_realtype */, Int number_2_written_digits);
113
115 bool OPENMS_DLLAPI
116 isRealSimilar(long double number_1, long double number_2);
117
125 void OPENMS_DLLAPI
126 testStringSimilar(const char* file, int line,
127 const std::string& string_1,
128 const char* string_1_stringified,
129 const std::string& string_2,
130 const char* string_2_stringified);
131
133 void OPENMS_DLLAPI
134 testStringEqual(const char* file, int line,
135 const std::string& string_1,
136 const char* string_1_stringified,
137 const std::string& string_2,
138 const char* string_2_stringified);
139
145 bool OPENMS_DLLAPI
146 isFileSimilar(const std::string& filename_1,
147 const std::string& filename_2);
148
150 void OPENMS_DLLAPI
152
154 void OPENMS_DLLAPI
155 printWithPrefix(const std::string& text, const int marked = -1);
156
166 void OPENMS_DLLAPI mainInit(const char* version, const char* class_name, int argc, const char* argv0);
167
177 void OPENMS_DLLAPI filesEqual(int line, const char* filename, const char* templatename, const char* filename_stringified, const char* templatename_stringified);
178
180 void OPENMS_DLLAPI removeTempFiles();
181
183 void OPENMS_DLLAPI
184 setWhitelist(const char* const /* file */, const int line,
185 const std::string& whitelist);
186
188 extern OPENMS_DLLAPI double ratio_max_allowed;
189
191 extern OPENMS_DLLAPI double ratio_max;
192
194 extern OPENMS_DLLAPI double ratio;
195
197 extern OPENMS_DLLAPI double absdiff_max_allowed;
198
200 extern OPENMS_DLLAPI double absdiff_max;
201
203 extern OPENMS_DLLAPI double absdiff;
204
205 extern OPENMS_DLLAPI int line_num_1_max;
206 extern OPENMS_DLLAPI int line_num_2_max;
207
209 extern OPENMS_DLLAPI int verbose;
210
212 extern OPENMS_DLLAPI bool all_tests;
213
215 extern OPENMS_DLLAPI bool test;
216
218 extern OPENMS_DLLAPI bool this_test;
219
221 extern OPENMS_DLLAPI int exception;
222
224 extern OPENMS_DLLAPI std::string exception_name;
225
227 extern OPENMS_DLLAPI std::string exception_message;
228
230 extern OPENMS_DLLAPI std::string test_name;
231
233 extern OPENMS_DLLAPI int start_section_line;
234
236 extern OPENMS_DLLAPI int test_line;
237
239 extern OPENMS_DLLAPI const char* version_string;
240
242 extern OPENMS_DLLAPI std::vector<std::string> tmp_file_list;
243
245 extern OPENMS_DLLAPI std::vector<UInt> failed_lines_list;
246
248 extern OPENMS_DLLAPI std::ifstream infile;
249
251 extern OPENMS_DLLAPI std::ifstream templatefile;
252
254 extern OPENMS_DLLAPI bool equal_files;
255
257 extern OPENMS_DLLAPI char line_buffer[65536];
258
260 extern OPENMS_DLLAPI int test_count;
261
263 extern OPENMS_DLLAPI std::string add_message;
264
269 extern OPENMS_DLLAPI std::string fuzzy_message;
270
272 extern OPENMS_DLLAPI bool newline;
273
274 template <typename T1, typename T2>
275 void
276 testEqual(const char* /*file*/, int line, const T1& expression_1,
277 const char* expression_1_stringified,
278 const T2& expression_2,
279 const char* expression_2_stringified)
280 {
281 ++test_count;
282 test_line = line;
283 // For std::string targets, stringify the comparison value rather than
284 // constructing std::string(expression_2): the old OpenMS::String had
285 // numeric/char converting constructors (e.g. String(114) == "114") that
286 // std::string lacks. StringUtils::toStr reproduces that behavior.
287 if constexpr (std::is_same_v<T1, std::string>)
288 {
289 this_test = bool(expression_1 == StringUtils::toStr(expression_2));
290 }
291 else
292 {
293 this_test = bool(expression_1 == T1(expression_2));
294 }
295 test &= this_test;
296 {
298 if (!this_test || verbose > 1)
299 {
300 stdcout << ' ' << (this_test ? '+' : '-') << " line " << line << " : TEST_EQUAL(" << expression_1_stringified << ','
301 << expression_2_stringified << "): got '";
302
303 // we can't print wide chars directly using operator<< so we need to test for it
304 if constexpr (std::is_same_v<std::remove_cv_t<T1>, XMLCh*> || std::is_same_v<std::remove_cv_t<T2>, XMLCh*>)
305 {
306 stdcout << (expression_1 == nullptr ? "(null)" : "(XMLCh*)") << "', expected '"
307 << (expression_2 == nullptr ? "(null)" : "(XMLCh*)") << "'\n";
308 }
309 else if constexpr (std::is_enum_v<T1> && std::is_enum_v<T2>)
310 {
311 stdcout << static_cast<int>(expression_1) << "', expected '" << static_cast<int>(expression_2) << "'\n";
312 }
313 else
314 {
315 stdcout << expression_1 << "', expected '" << expression_2 << "'\n";
316 }
317 }
318 if (!this_test)
319 {
320 failed_lines_list.push_back(line);
321 }
322 }
323 }
324
325 void testTrue(const char* /*file*/, int line, const bool expression_1, const char* expression_1_stringified)
326 {
327 ++test_count;
328 test_line = line;
329 this_test = expression_1;
330 test &= this_test;
331 {
333 if (this_test)
334 {
335 if (verbose > 1)
336 {
337 stdcout << " + line " << line << ": TEST_TRUE(" << expression_1_stringified << "): ok\n";
338 }
339 }
340 else
341 {
342 stdcout << " - line " << line << ": TEST_TRUE(" << expression_1_stringified << "): failed\n";
343 failed_lines_list.push_back(line);
344 }
345 }
346 }
347
348 void testFalse(const char* /*file*/, int line, const bool expression_1, const char* expression_1_stringified)
349 {
350 ++test_count;
351 test_line = line;
352 this_test = !expression_1;
353 test &= this_test;
354 {
356 if (this_test)
357 {
358 if (verbose > 1)
359 {
360 stdcout << " + line " << line << ": TEST_FALSE(" << expression_1_stringified << "): ok\n";
361 }
362 }
363 else
364 {
365 stdcout << " - line " << line << ": TEST_FALSE(" << expression_1_stringified << "): failed\n";
366 failed_lines_list.push_back(line);
367 }
368 }
369 }
370
371 template <typename T1, typename T2>
372 void
373 testNotEqual(const char* /*file*/, int line, const T1& expression_1,
374 const char* expression_1_stringified,
375 const T2& expression_2,
376 const char* expression_2_stringified)
377 {
378 ++test_count;
379 test_line = line;
380 this_test = !(expression_1 == T1(expression_2));
381 test &= this_test;
382 {
384 if (!this_test || verbose > 1)
385 {
386 stdcout << ' ' << (this_test ? '+' : '-') << " line " << line << " : TEST_NOT_EQUAL(" << expression_1_stringified << ','
387 << expression_2_stringified << "): got '";
388 if constexpr (std::is_enum_v<T1> && std::is_enum_v<T2>)
389 {
390 stdcout << static_cast<int>(expression_1) << "', forbidden is '" << static_cast<int>(expression_2) << "'\n";
391 }
392 else { stdcout << expression_1 << "', expected '" << expression_2 << "'\n"; }
393 }
394 if (!this_test)
395 {
396 failed_lines_list.push_back(line);
397 }
398 }
399 }
400
401
402 void OPENMS_DLLAPI printLastException(std::ostream& out);
403
404 int OPENMS_DLLAPI endTestPostProcess(std::ostream& out);
405
406 void OPENMS_DLLAPI endSectionPostProcess(std::ostream& out, const int line);
407 }
408 }
409}
410
411// A namespace alias - apparently these cannot be documented using doxygen (?)
413
438
439//@name test and subtest
441
466#define START_TEST(class_name, version) \
467 int main(int argc, char** argv) \
468 { \
469 TEST::mainInit(version, #class_name, argc, argv[0]); \
470 try {
471
483#define END_TEST \
484 /* global try block */ \
485 } \
486 catch (...) \
487 { \
488 TEST::printLastException(stdcout); \
489 } \
490 return TEST::endTestPostProcess(stdcout); \
491 }
492
514#define START_SECTION(name_of_test) \
515 TEST::test = true; \
516 TEST::newline = false; \
517 TEST::test_name = # name_of_test; \
518 TEST::test_count = 0; \
519 TEST::start_section_line = __LINE__; \
520 stdcout << "checking " << TEST::test_name << " ... " << std::flush; \
521 try \
522 { \
523 while (true) \
524 {
525
551#define END_SECTION \
552 break; \
553 } \
554 } \
555 catch (...) \
556 { \
557 TEST::printLastException(stdcout);\
558 } \
559 TEST::endSectionPostProcess(stdcout, __LINE__);
560
561
563
583#define TEST_EQUAL(a, b) TEST::testEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
584
594#define TEST_TRUE(a) TEST::testTrue(__FILE__, __LINE__, (a), (#a));
595
605#define TEST_FALSE(a) TEST::testFalse(__FILE__, __LINE__, (a), (#a));
606
607
619#define TEST_NOT_EQUAL(a, b) TEST::testNotEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
620
633#define TEST_STRING_EQUAL(a, b) TEST::testStringEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
634
649#define TEST_FILE_EQUAL(filename, templatename) \
650 { \
651 TEST::filesEqual(__LINE__, filename, templatename, #filename, #templatename); \
652 }
653
669#define TEST_REAL_SIMILAR(a, b) TEST::testRealSimilar(__FILE__, __LINE__, (a), (# a), TEST::isRealType(a), writtenDigits(a), (b), (# b), TEST::isRealType(b), writtenDigits(b));
670
686#define TEST_STRING_SIMILAR(a, b) TEST::testStringSimilar(__FILE__, __LINE__, (a), (# a), (b), (# b));
687
702#define TEST_FILE_SIMILAR(a, b) \
703 { \
704 ++TEST::test_count; \
705 TEST::test_line = __LINE__; \
706 TEST::this_test = TEST::isFileSimilar((a), (b)); \
707 TEST::test = TEST::test && TEST::this_test; \
708 { \
709 TEST::initialNewline(); \
710 if (TEST::this_test) \
711 { \
712 if (TEST::verbose > 1) \
713 { \
714 stdcout << " + line " << __LINE__ \
715 << ": TEST_FILE_SIMILAR(" # a "," # b "): absolute: " \
716 << precisionWrapper(TEST::absdiff) \
717 << " (" \
718 << precisionWrapper(TEST::absdiff_max_allowed) \
719 << "), relative: " \
720 << precisionWrapper(TEST::ratio) \
721 << " (" \
722 << precisionWrapper(TEST::ratio_max_allowed) \
723 << ")\n"; \
724 stdcout << "message: \n"; \
725 stdcout << TEST::fuzzy_message; \
726 } \
727 } \
728 else \
729 { \
730 stdcout << " - line " << TEST::test_line << \
731 ": TEST_FILE_SIMILAR(" # a "," # b ") ... -\n"; \
732 stdcout << "message: \n"; \
733 stdcout << TEST::fuzzy_message; \
734 TEST::failed_lines_list.push_back(TEST::test_line); \
735 } \
736 } \
737 }
738
751#define TOLERANCE_RELATIVE(a) \
752 TEST::ratio_max_allowed = (a); \
753 { \
754 TEST::initialNewline(); \
755 if (TEST::verbose > 1) \
756 { \
757 stdcout << " + line " << __LINE__ << \
758 ": TOLERANCE_RELATIVE(" << TEST::ratio_max_allowed << \
759 ") (\"" # a "\")\n"; \
760 } \
761 }
762
774#define TOLERANCE_ABSOLUTE(a) \
775 TEST::absdiff_max_allowed = (a); \
776 { \
777 TEST::initialNewline(); \
778 if (TEST::verbose > 1) \
779 { \
780 stdcout << " + line " << __LINE__ << \
781 ": TOLERANCE_ABSOLUTE(" << TEST::absdiff_max_allowed << \
782 ") (\"" # a "\")\n"; \
783 } \
784 }
785
791#define WHITELIST(a) TEST::setWhitelist(__FILE__, __LINE__, (a));
792
805#define TEST_EXCEPTION(exception_type, command) \
806 { \
807 ++TEST::test_count; \
808 TEST::test_line = __LINE__; \
809 TEST::exception = 0; \
810 try \
811 { \
812 command; \
813 } \
814 catch (exception_type&) \
815 { \
816 TEST::exception = 1; \
817 } \
818 catch (::OpenMS::Exception::BaseException& e) \
819 { \
820 TEST::exception = 2; \
821 TEST::exception_name = e.getName(); \
822 } \
823 catch (const std::exception& e) \
824 { \
825 TEST::exception = 3; \
826 TEST::exception_name = e.what(); \
827 } \
828 catch (...) \
829 { \
830 TEST::exception = 4; \
831 } \
832 TEST::this_test = (TEST::exception == 1); \
833 TEST::test = TEST::test && TEST::this_test; \
834 { \
835 TEST::initialNewline(); \
836 switch (TEST::exception) \
837 { \
838 case 0: \
839 stdcout << " - line " << TEST::test_line << \
840 ": TEST_EXCEPTION(" # exception_type "," # command \
841 "): no exception thrown!\n"; \
842 TEST::failed_lines_list.push_back(TEST::test_line); \
843 break; \
844 case 1: \
845 if (TEST::verbose > 1) \
846 { \
847 stdcout << " + line " << TEST::test_line << \
848 ": TEST_EXCEPTION(" # exception_type "," # command \
849 "): OK\n"; \
850 } \
851 break; \
852 case 2: \
853 stdcout << " - line " << TEST::test_line << \
854 ": TEST_EXCEPTION(" # exception_type "," # command \
855 "): wrong exception thrown! \"" \
856 << TEST::exception_name << "\"\n"; \
857 TEST::failed_lines_list.push_back(TEST::test_line); \
858 break; \
859 case 3: \
860 stdcout << " - line " << TEST::test_line << \
861 ": TEST_EXCEPTION(" # exception_type "," # command \
862 "): wrong exception thrown! \"" \
863 << TEST::exception_name << "\"\n"; \
864 TEST::failed_lines_list.push_back(TEST::test_line); \
865 break; \
866 case 4: \
867 stdcout << " - line " << TEST::test_line << \
868 ": TEST_EXCEPTION(" # exception_type "," # command \
869 "): wrong exception thrown!\n"; \
870 TEST::failed_lines_list.push_back(TEST::test_line); \
871 break; \
872 } \
873 } \
874 }
875
887#ifdef OPENMS_ASSERTIONS
888#define TEST_PRECONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Precondition, command);
889#else
890#define TEST_PRECONDITION_VIOLATED(command) STATUS("TEST_PRECONDITION_VIOLATED(" # command ") - skipped");
891#endif
892
904#ifdef OPENMS_ASSERTIONS
905#define TEST_POSTCONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Postcondition, command);
906#else
907#define TEST_POSTCONDITION_VIOLATED(command) STATUS("TEST_POSTCONDITION_VIOLATED(" # command ") - skipped");
908#endif
909
910
927#define TEST_EXCEPTION_WITH_MESSAGE(exception_type, command, message) \
928 { \
929 ++TEST::test_count; \
930 TEST::test_line = __LINE__; \
931 TEST::exception = 0; \
932 try \
933 { \
934 command; \
935 } \
936 catch (exception_type& et) \
937 { \
938 if (std::string(et.what()) != std::string(message)) \
939 { \
940 TEST::exception = 4; \
941 TEST::exception_message = et.what(); \
942 } \
943 else TEST::exception = 1; \
944 } \
945 catch (::OpenMS::Exception::BaseException& e) \
946 { \
947 TEST::exception = 2; \
948 TEST::exception_name = e.getName(); \
949 } \
950 catch (...) \
951 { \
952 TEST::exception = 3; \
953 } \
954 TEST::this_test = (TEST::exception == 1); \
955 TEST::test = TEST::test && TEST::this_test; \
956 \
957 { \
958 TEST::initialNewline(); \
959 switch (TEST::exception) \
960 { \
961 case 0: \
962 stdcout << " - line " << TEST::test_line << \
963 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
964 "): no exception thrown!\n"; \
965 TEST::failed_lines_list.push_back(TEST::test_line); \
966 break; \
967 case 1: \
968 if (TEST::verbose > 1) \
969 { \
970 /* this is actually what we want to get: */ \
971 stdcout << " + line " << TEST::test_line << \
972 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
973 "): OK\n"; \
974 } \
975 break; \
976 case 2: \
977 stdcout << " - line " << TEST::test_line << \
978 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
979 "): wrong exception thrown! \"" << \
980 TEST::exception_name << "\"\n"; \
981 TEST::failed_lines_list.push_back(TEST::test_line); \
982 break; \
983 case 3: \
984 stdcout << " - line " << TEST::test_line << \
985 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
986 "): wrong exception thrown!\n"; \
987 TEST::failed_lines_list.push_back(TEST::test_line); \
988 break; \
989 case 4: \
990 stdcout << " - line " << TEST::test_line << \
991 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
992 "): exception has wrong message: got '" << \
993 TEST::exception_message << \
994 "', expected '" << \
995 (message) << "'\n"; \
996 TEST::failed_lines_list.push_back(TEST::test_line); \
997 break; \
998 } \
999 } \
1000 }
1001
1015#define NEW_TMP_FILE_EXT(filename, extension) filename = TEST::createTmpFileName(__FILE__, __LINE__, extension);
1016
1017
1018#define NEW_TMP_FILE(filename) filename = TEST::createTmpFileName(__FILE__, __LINE__);
1019
1020
1028#define ABORT_IF(condition) \
1029 if (condition) \
1030 { \
1031 { \
1032 TEST::test_line = __LINE__; \
1033 TEST::this_test = false; \
1034 TEST::test = TEST::test && TEST::this_test; \
1035 TEST::failed_lines_list.push_back(TEST::test_line); \
1036 TEST::initialNewline(); \
1037 stdcout << " - line " << TEST::test_line << \
1038 ": ABORT_IF(" # condition "): TEST ABORTED\n"; \
1039 } \
1040 break; \
1041 }
1042
1060#define STATUS(message) \
1061 { \
1062 TEST::initialNewline(); \
1063 stdcout << " line " \
1064 << __LINE__ \
1065 << ": status: " \
1066 << message \
1067 << "\n"; \
1068 }
1069
1079#define ADD_MESSAGE(message) \
1080 TEST::add_message = message;
1081
1091#define NOT_TESTABLE \
1092 TEST::test_count = 1;
1093
char16_t XMLCh
Definition ClassTest.h:30
#define stdcout
Provide a point of redirection for testing the test macros, see ClassTest_test.cpp.
Definition ClassTest.h:37
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition DataValue.h:33
Class to hold strings, numeric values, vectors of strings and vectors of numeric values using the stl...
Definition ParamValue.h:31
int Int
Signed integer type.
Definition Types.h:72
Namespace for class tests.
Definition ClassTest.h:46
double ratio_max
Maximum ratio of numbers observed so far, see TOLERANCE_RELATIVE.
int verbose
Verbosity level ( "-v" is 1 and "-V" is 2 )
void testEqual(const char *, int line, const T1 &expression_1, const char *expression_1_stringified, const T2 &expression_2, const char *expression_2_stringified)
Definition ClassTest.h:276
int test_count
Counter for the number of elementary tests within the current subsection.
void testStringSimilar(const char *file, int line, const std::string &string_1, const char *string_1_stringified, const std::string &string_2, const char *string_2_stringified)
Compare strings using absdiff_max_allowed and ratio_max_allowed.
void testFalse(const char *, int line, const bool expression_1, const char *expression_1_stringified)
Definition ClassTest.h:348
bool isRealSimilar(long double number_1, long double number_2)
used by testRealSimilar()
int test_line
Line of current elementary test.
double absdiff
Recent absolute difference of numbers, see TOLERANCE_ABSOLUTE.
char line_buffer[65536]
(A buffer for one line from a file. Used by TEST_FILE_EQUAL.)
std::string add_message
See ADD_MESSAGE.
void endSectionPostProcess(std::ostream &out, const int line)
bool validate(const std::vector< std::string > &file_names)
Validates the given files against the XML schema (if available)
void testRealSimilar(const char *file, int line, long double number_1, const char *number_1_stringified, bool number_1_is_realtype, Int number_1_written_digits, long double number_2, const char *number_2_stringified, bool, Int number_2_written_digits)
Compare floating point numbers using absdiff_max_allowed and ratio_max_allowed.
std::string fuzzy_message
Last message from a fuzzy comparison. Written by isRealSimilar(), testStringSimilar(),...
bool isRealType(float)
This overload returns true; float is a floating point type.
Definition ClassTest.h:61
void initialNewline()
make sure we have a newline before results from first subtest
bool all_tests
Status of the whole test.
std::string exception_message
(Used by various macros. Stores the "message" of the exception, if applicable.)
std::string test_name
Name of current subsection.
void testNotEqual(const char *, int line, const T1 &expression_1, const char *expression_1_stringified, const T2 &expression_2, const char *expression_2_stringified)
Definition ClassTest.h:373
double absdiff_max
Maximum difference of numbers observed so far, see TOLERANCE_ABSOLUTE.
bool newline
(Flags whether a new line is in place, depending on context and verbosity setting....
void filesEqual(int line, const char *filename, const char *templatename, const char *filename_stringified, const char *templatename_stringified)
Test if two files are exactly equal (used in TEST_FILE_EQUAL macro)
bool test
Status of the current subsection.
double absdiff_max_allowed
Maximum absolute difference of numbers allowed, see TOLERANCE_ABSOLUTE.
void testStringEqual(const char *file, int line, const std::string &string_1, const char *string_1_stringified, const std::string &string_2, const char *string_2_stringified)
used by TEST_STRING_EQUAL
const char * version_string
Version string supplied with START_TEST.
std::ifstream infile
Questionable file tested by TEST_FILE_EQUAL.
int endTestPostProcess(std::ostream &out)
std::string exception_name
(Used by various macros. Stores the "name" of the exception, if applicable.)
std::vector< UInt > failed_lines_list
List of all failed lines for summary at the end of the test.
void mainInit(const char *version, const char *class_name, int argc, const char *argv0)
Set up some classtest variables as obtained from the 'START_TEST' macro and check that no additional ...
double ratio
Recent ratio of numbers, see TOLERANCE_RELATIVE.
void removeTempFiles()
removed all temporary files created with the NEW_TMP_FILE macro
std::vector< std::string > tmp_file_list
List of tmp file names (these will be cleaned up, see NEW_TMP_FILE)
bool isFileSimilar(const std::string &filename_1, const std::string &filename_2)
Compare files using absdiff_max_allowed and ratio_max_allowed.
bool this_test
Status of last elementary test.
void printLastException(std::ostream &out)
std::string createTmpFileName(const std::string &file, int line, const std::string &extension="")
Creates a temporary file name from the test name and the line with the specified extension.
std::ifstream templatefile
Template (correct) file used by TEST_FILE_EQUAL.
void testTrue(const char *, int line, const bool expression_1, const char *expression_1_stringified)
Definition ClassTest.h:325
double ratio_max_allowed
Maximum ratio of numbers allowed, see TOLERANCE_RELATIVE.
void printWithPrefix(const std::string &text, const int marked=-1)
print the text, each line gets a prefix, the marked line number gets a special prefix
bool equal_files
(A variable used by TEST_FILE_EQUAL)
int start_section_line
Line where current subsection started.
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
void setWhitelist(const char *const, const int line, const std::string &whitelist)
set the whitelist_
std::string toStr(int i)
Definition StringUtils.h:101
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19