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
515#define START_SECTION(name_of_test) \
516 TEST::test = true; \
517 TEST::newline = false; \
518 TEST::test_name = # name_of_test; \
519 TEST::test_count = 0; \
520 TEST::start_section_line = __LINE__; \
521 stdcout << "checking " << TEST::test_name << " ... " << std::flush; \
522 try \
523 { \
524 while (true) \
525 {
526
552#define END_SECTION \
553 break; \
554 } \
555 } \
556 catch (...) \
557 { \
558 TEST::printLastException(stdcout);\
559 } \
560 TEST::endSectionPostProcess(stdcout, __LINE__);
561
562
564
584#define TEST_EQUAL(a, b) TEST::testEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
585
595#define TEST_TRUE(a) TEST::testTrue(__FILE__, __LINE__, (a), (#a));
596
606#define TEST_FALSE(a) TEST::testFalse(__FILE__, __LINE__, (a), (#a));
607
608
620#define TEST_NOT_EQUAL(a, b) TEST::testNotEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
621
634#define TEST_STRING_EQUAL(a, b) TEST::testStringEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
635
650#define TEST_FILE_EQUAL(filename, templatename) \
651 { \
652 TEST::filesEqual(__LINE__, filename, templatename, #filename, #templatename); \
653 }
654
670#define TEST_REAL_SIMILAR(a, b) TEST::testRealSimilar(__FILE__, __LINE__, (a), (# a), TEST::isRealType(a), writtenDigits(a), (b), (# b), TEST::isRealType(b), writtenDigits(b));
671
687#define TEST_STRING_SIMILAR(a, b) TEST::testStringSimilar(__FILE__, __LINE__, (a), (# a), (b), (# b));
688
703#define TEST_FILE_SIMILAR(a, b) \
704 { \
705 ++TEST::test_count; \
706 TEST::test_line = __LINE__; \
707 TEST::this_test = TEST::isFileSimilar((a), (b)); \
708 TEST::test = TEST::test && TEST::this_test; \
709 { \
710 TEST::initialNewline(); \
711 if (TEST::this_test) \
712 { \
713 if (TEST::verbose > 1) \
714 { \
715 stdcout << " + line " << __LINE__ \
716 << ": TEST_FILE_SIMILAR(" # a "," # b "): absolute: " \
717 << precisionWrapper(TEST::absdiff) \
718 << " (" \
719 << precisionWrapper(TEST::absdiff_max_allowed) \
720 << "), relative: " \
721 << precisionWrapper(TEST::ratio) \
722 << " (" \
723 << precisionWrapper(TEST::ratio_max_allowed) \
724 << ")\n"; \
725 stdcout << "message: \n"; \
726 stdcout << TEST::fuzzy_message; \
727 } \
728 } \
729 else \
730 { \
731 stdcout << " - line " << TEST::test_line << \
732 ": TEST_FILE_SIMILAR(" # a "," # b ") ... -\n"; \
733 stdcout << "message: \n"; \
734 stdcout << TEST::fuzzy_message; \
735 TEST::failed_lines_list.push_back(TEST::test_line); \
736 } \
737 } \
738 }
739
752#define TOLERANCE_RELATIVE(a) \
753 TEST::ratio_max_allowed = (a); \
754 { \
755 TEST::initialNewline(); \
756 if (TEST::verbose > 1) \
757 { \
758 stdcout << " + line " << __LINE__ << \
759 ": TOLERANCE_RELATIVE(" << TEST::ratio_max_allowed << \
760 ") (\"" # a "\")\n"; \
761 } \
762 }
763
775#define TOLERANCE_ABSOLUTE(a) \
776 TEST::absdiff_max_allowed = (a); \
777 { \
778 TEST::initialNewline(); \
779 if (TEST::verbose > 1) \
780 { \
781 stdcout << " + line " << __LINE__ << \
782 ": TOLERANCE_ABSOLUTE(" << TEST::absdiff_max_allowed << \
783 ") (\"" # a "\")\n"; \
784 } \
785 }
786
792#define WHITELIST(a) TEST::setWhitelist(__FILE__, __LINE__, (a));
793
806#define TEST_EXCEPTION(exception_type, command) \
807 { \
808 ++TEST::test_count; \
809 TEST::test_line = __LINE__; \
810 TEST::exception = 0; \
811 try \
812 { \
813 command; \
814 } \
815 catch (exception_type&) \
816 { \
817 TEST::exception = 1; \
818 } \
819 catch (::OpenMS::Exception::BaseException& e) \
820 { \
821 TEST::exception = 2; \
822 TEST::exception_name = e.getName(); \
823 } \
824 catch (const std::exception& e) \
825 { \
826 TEST::exception = 3; \
827 TEST::exception_name = e.what(); \
828 } \
829 catch (...) \
830 { \
831 TEST::exception = 4; \
832 } \
833 TEST::this_test = (TEST::exception == 1); \
834 TEST::test = TEST::test && TEST::this_test; \
835 { \
836 TEST::initialNewline(); \
837 switch (TEST::exception) \
838 { \
839 case 0: \
840 stdcout << " - line " << TEST::test_line << \
841 ": TEST_EXCEPTION(" # exception_type "," # command \
842 "): no exception thrown!\n"; \
843 TEST::failed_lines_list.push_back(TEST::test_line); \
844 break; \
845 case 1: \
846 if (TEST::verbose > 1) \
847 { \
848 stdcout << " + line " << TEST::test_line << \
849 ": TEST_EXCEPTION(" # exception_type "," # command \
850 "): OK\n"; \
851 } \
852 break; \
853 case 2: \
854 stdcout << " - line " << TEST::test_line << \
855 ": TEST_EXCEPTION(" # exception_type "," # command \
856 "): wrong exception thrown! \"" \
857 << TEST::exception_name << "\"\n"; \
858 TEST::failed_lines_list.push_back(TEST::test_line); \
859 break; \
860 case 3: \
861 stdcout << " - line " << TEST::test_line << \
862 ": TEST_EXCEPTION(" # exception_type "," # command \
863 "): wrong exception thrown! \"" \
864 << TEST::exception_name << "\"\n"; \
865 TEST::failed_lines_list.push_back(TEST::test_line); \
866 break; \
867 case 4: \
868 stdcout << " - line " << TEST::test_line << \
869 ": TEST_EXCEPTION(" # exception_type "," # command \
870 "): wrong exception thrown!\n"; \
871 TEST::failed_lines_list.push_back(TEST::test_line); \
872 break; \
873 } \
874 } \
875 }
876
888#ifdef OPENMS_ASSERTIONS
889#define TEST_PRECONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Precondition, command);
890#else
891#define TEST_PRECONDITION_VIOLATED(command) STATUS("TEST_PRECONDITION_VIOLATED(" # command ") - skipped");
892#endif
893
905#ifdef OPENMS_ASSERTIONS
906#define TEST_POSTCONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Postcondition, command);
907#else
908#define TEST_POSTCONDITION_VIOLATED(command) STATUS("TEST_POSTCONDITION_VIOLATED(" # command ") - skipped");
909#endif
910
911
928#define TEST_EXCEPTION_WITH_MESSAGE(exception_type, command, message) \
929 { \
930 ++TEST::test_count; \
931 TEST::test_line = __LINE__; \
932 TEST::exception = 0; \
933 try \
934 { \
935 command; \
936 } \
937 catch (exception_type& et) \
938 { \
939 if (std::string(et.what()) != std::string(message)) \
940 { \
941 TEST::exception = 4; \
942 TEST::exception_message = et.what(); \
943 } \
944 else TEST::exception = 1; \
945 } \
946 catch (::OpenMS::Exception::BaseException& e) \
947 { \
948 TEST::exception = 2; \
949 TEST::exception_name = e.getName(); \
950 } \
951 catch (...) \
952 { \
953 TEST::exception = 3; \
954 } \
955 TEST::this_test = (TEST::exception == 1); \
956 TEST::test = TEST::test && TEST::this_test; \
957 \
958 { \
959 TEST::initialNewline(); \
960 switch (TEST::exception) \
961 { \
962 case 0: \
963 stdcout << " - line " << TEST::test_line << \
964 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
965 "): no exception thrown!\n"; \
966 TEST::failed_lines_list.push_back(TEST::test_line); \
967 break; \
968 case 1: \
969 if (TEST::verbose > 1) \
970 { \
971 /* this is actually what we want to get: */ \
972 stdcout << " + line " << TEST::test_line << \
973 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
974 "): OK\n"; \
975 } \
976 break; \
977 case 2: \
978 stdcout << " - line " << TEST::test_line << \
979 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
980 "): wrong exception thrown! \"" << \
981 TEST::exception_name << "\"\n"; \
982 TEST::failed_lines_list.push_back(TEST::test_line); \
983 break; \
984 case 3: \
985 stdcout << " - line " << TEST::test_line << \
986 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
987 "): wrong exception thrown!\n"; \
988 TEST::failed_lines_list.push_back(TEST::test_line); \
989 break; \
990 case 4: \
991 stdcout << " - line " << TEST::test_line << \
992 ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
993 "): exception has wrong message: got '" << \
994 TEST::exception_message << \
995 "', expected '" << \
996 (message) << "'\n"; \
997 TEST::failed_lines_list.push_back(TEST::test_line); \
998 break; \
999 } \
1000 } \
1001 }
1002
1016#define NEW_TMP_FILE_EXT(filename, extension) filename = TEST::createTmpFileName(__FILE__, __LINE__, extension);
1017
1018
1019#define NEW_TMP_FILE(filename) filename = TEST::createTmpFileName(__FILE__, __LINE__);
1020
1021
1029#define ABORT_IF(condition) \
1030 if (condition) \
1031 { \
1032 { \
1033 TEST::test_line = __LINE__; \
1034 TEST::this_test = false; \
1035 TEST::test = TEST::test && TEST::this_test; \
1036 TEST::failed_lines_list.push_back(TEST::test_line); \
1037 TEST::initialNewline(); \
1038 stdcout << " - line " << TEST::test_line << \
1039 ": ABORT_IF(" # condition "): TEST ABORTED\n"; \
1040 } \
1041 break; \
1042 }
1043
1061#define STATUS(message) \
1062 { \
1063 TEST::initialNewline(); \
1064 stdcout << " line " \
1065 << __LINE__ \
1066 << ": status: " \
1067 << message \
1068 << "\n"; \
1069 }
1070
1080#define ADD_MESSAGE(message) \
1081 TEST::add_message = message;
1082
1092#define NOT_TESTABLE \
1093 TEST::test_count = 1;
1094
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:32
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:257
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19