OpenMS
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...
16 #include <OpenMS/CONCEPT/Types.h>
19 #include <OpenMS/OpenMSConfig.h>
20 #include <OpenMS/config.h>
21 
22 #include <cstring>
23 #include <iostream>
24 #include <string>
25 #include <vector>
26 #include <type_traits>
27 
28 using XMLCh = char16_t; // Xerces-C++ uses char16_t for UTF-16 strings that we need to output in tests
29 
30 // Empty declaration to avoid problems in case the namespace is not
31 // yet defined (e.g. TEST/ClassTest_test.cpp)
32 
34 #ifndef stdcout
35 #define stdcout std::cout
36 #endif
37 
38 namespace OpenMS
39 {
40  namespace Internal
41  {
43  namespace ClassTest
44  {
45 
50  bool OPENMS_DLLAPI
51  validate(const std::vector<std::string>& file_names);
52 
54  std::string OPENMS_DLLAPI
55  createTmpFileName(const std::string& file, int line, const std::string& extension = "");
56 
58  inline bool OPENMS_DLLAPI
59  isRealType(float)
60  {
61  return true;
62  }
63 
65  inline bool OPENMS_DLLAPI
66  isRealType(double)
67  {
68  return true;
69  }
70 
72  inline bool OPENMS_DLLAPI
73  isRealType(long double)
74  {
75  return true;
76  }
77 
79  inline bool OPENMS_DLLAPI
81  {
82  return true;
83  }
84 
86  inline bool OPENMS_DLLAPI
88  {
89  return true;
90  }
91 
93  template <typename T>
94  inline bool
95  isRealType(const T&)
96  {
97  return false;
98  }
99 
105  void OPENMS_DLLAPI
106  testRealSimilar(const char* file, int line, long double number_1,
107  const char* number_1_stringified,
108  bool number_1_is_realtype, Int number_1_written_digits,
109  long double number_2, const char* number_2_stringified,
110  bool /* number_2_is_realtype */, Int number_2_written_digits);
111 
113  bool OPENMS_DLLAPI
114  isRealSimilar(long double number_1, long double number_2);
115 
123  void OPENMS_DLLAPI
124  testStringSimilar(const char* file, int line,
125  const std::string& string_1,
126  const char* string_1_stringified,
127  const std::string& string_2,
128  const char* string_2_stringified);
129 
131  void OPENMS_DLLAPI
132  testStringEqual(const char* file, int line,
133  const std::string& string_1,
134  const char* string_1_stringified,
135  const std::string& string_2,
136  const char* string_2_stringified);
137 
143  bool OPENMS_DLLAPI
144  isFileSimilar(const std::string& filename_1,
145  const std::string& filename_2);
146 
148  void OPENMS_DLLAPI
150 
152  void OPENMS_DLLAPI
153  printWithPrefix(const std::string& text, const int marked = -1);
154 
164  void OPENMS_DLLAPI mainInit(const char* version, const char* class_name, int argc, const char* argv0);
165 
175  void OPENMS_DLLAPI filesEqual(int line, const char* filename, const char* templatename, const char* filename_stringified, const char* templatename_stringified);
176 
178  void OPENMS_DLLAPI removeTempFiles();
179 
181  void OPENMS_DLLAPI
182  setWhitelist(const char* const /* file */, const int line,
183  const std::string& whitelist);
184 
186  extern OPENMS_DLLAPI double ratio_max_allowed;
187 
189  extern OPENMS_DLLAPI double ratio_max;
190 
192  extern OPENMS_DLLAPI double ratio;
193 
195  extern OPENMS_DLLAPI double absdiff_max_allowed;
196 
198  extern OPENMS_DLLAPI double absdiff_max;
199 
201  extern OPENMS_DLLAPI double absdiff;
202 
203  extern OPENMS_DLLAPI int line_num_1_max;
204  extern OPENMS_DLLAPI int line_num_2_max;
205 
207  extern OPENMS_DLLAPI int verbose;
208 
210  extern OPENMS_DLLAPI bool all_tests;
211 
213  extern OPENMS_DLLAPI bool test;
214 
216  extern OPENMS_DLLAPI bool this_test;
217 
219  extern OPENMS_DLLAPI int exception;
220 
222  extern OPENMS_DLLAPI std::string exception_name;
223 
225  extern OPENMS_DLLAPI std::string exception_message;
226 
228  extern OPENMS_DLLAPI std::string test_name;
229 
231  extern OPENMS_DLLAPI int start_section_line;
232 
234  extern OPENMS_DLLAPI int test_line;
235 
237  extern OPENMS_DLLAPI const char* version_string;
238 
240  extern OPENMS_DLLAPI std::vector<std::string> tmp_file_list;
241 
243  extern OPENMS_DLLAPI std::vector<UInt> failed_lines_list;
244 
246  extern OPENMS_DLLAPI std::ifstream infile;
247 
249  extern OPENMS_DLLAPI std::ifstream templatefile;
250 
252  extern OPENMS_DLLAPI bool equal_files;
253 
255  extern OPENMS_DLLAPI char line_buffer[65536];
256 
258  extern OPENMS_DLLAPI int test_count;
259 
261  extern OPENMS_DLLAPI std::string add_message;
262 
267  extern OPENMS_DLLAPI std::string fuzzy_message;
268 
270  extern OPENMS_DLLAPI bool newline;
271 
272  template <typename T1, typename T2>
273  void
274  testEqual(const char* /*file*/, int line, const T1& expression_1,
275  const char* expression_1_stringified,
276  const T2& expression_2,
277  const char* expression_2_stringified)
278  {
279  ++test_count;
280  test_line = line;
281  this_test = bool(expression_1 == T1(expression_2)) ;
282  test &= this_test;
283  {
284  initialNewline();
285  if (!this_test || verbose > 1)
286  {
287  stdcout << ' ' << (this_test ? '+' : '-') << " line " << line << " : TEST_EQUAL(" << expression_1_stringified << ','
288  << expression_2_stringified << "): got '";
289 
290  // we can't print wide chars directly using operator<< so we need to test for it
291  if constexpr (std::is_same_v<std::remove_cv_t<T1>, XMLCh*> || std::is_same_v<std::remove_cv_t<T2>, XMLCh*>)
292  {
293  stdcout << (expression_1 == nullptr ? "(null)" : "(XMLCh*)") << "', expected '"
294  << (expression_2 == nullptr ? "(null)" : "(XMLCh*)") << "'\n";
295  }
296  else if constexpr (std::is_enum_v<T1> && std::is_enum_v<T2>)
297  {
298  stdcout << static_cast<int>(expression_1) << "', expected '" << static_cast<int>(expression_2) << "'\n";
299  }
300  else
301  {
302  stdcout << expression_1 << "', expected '" << expression_2 << "'\n";
303  }
304  }
305  if (!this_test)
306  {
307  failed_lines_list.push_back(line);
308  }
309  }
310  }
311 
312  void testTrue(const char* /*file*/, int line, const bool expression_1, const char* expression_1_stringified)
313  {
314  ++test_count;
315  test_line = line;
316  this_test = expression_1;
317  test &= this_test;
318  {
319  initialNewline();
320  if (this_test)
321  {
322  if (verbose > 1)
323  {
324  stdcout << " + line " << line << ": TEST_TRUE(" << expression_1_stringified << "): ok\n";
325  }
326  }
327  else
328  {
329  stdcout << " - line " << line << ": TEST_TRUE(" << expression_1_stringified << "): failed\n";
330  failed_lines_list.push_back(line);
331  }
332  }
333  }
334 
335  void testFalse(const char* /*file*/, int line, const bool expression_1, const char* expression_1_stringified)
336  {
337  ++test_count;
338  test_line = line;
339  this_test = !expression_1;
340  test &= this_test;
341  {
342  initialNewline();
343  if (this_test)
344  {
345  if (verbose > 1)
346  {
347  stdcout << " + line " << line << ": TEST_FALSE(" << expression_1_stringified << "): ok\n";
348  }
349  }
350  else
351  {
352  stdcout << " - line " << line << ": TEST_FALSE(" << expression_1_stringified << "): failed\n";
353  failed_lines_list.push_back(line);
354  }
355  }
356  }
357 
358  template <typename T1, typename T2>
359  void
360  testNotEqual(const char* /*file*/, int line, const T1& expression_1,
361  const char* expression_1_stringified,
362  const T2& expression_2,
363  const char* expression_2_stringified)
364  {
365  ++test_count;
366  test_line = line;
367  this_test = !(expression_1 == T1(expression_2));
368  test &= this_test;
369  {
370  initialNewline();
371  if (!this_test || verbose > 1)
372  {
373  stdcout << ' ' << (this_test ? '+' : '-') << " line " << line << " : TEST_NOT_EQUAL(" << expression_1_stringified << ','
374  << expression_2_stringified << "): got '";
375  if constexpr (std::is_enum_v<T1> && std::is_enum_v<T2>)
376  {
377  stdcout << static_cast<int>(expression_1) << "', forbidden is '" << static_cast<int>(expression_2) << "'\n";
378  }
379  else { stdcout << expression_1 << "', expected '" << expression_2 << "'\n"; }
380  }
381  if (!this_test)
382  {
383  failed_lines_list.push_back(line);
384  }
385  }
386  }
387 
388 
389  void OPENMS_DLLAPI printLastException(std::ostream& out);
390 
391  int OPENMS_DLLAPI endTestPostProcess(std::ostream& out);
392 
393  void OPENMS_DLLAPI endSectionPostProcess(std::ostream& out, const int line);
394  }
395  }
396 }
397 
398 // A namespace alias - apparently these cannot be documented using doxygen (?)
400 
425 
426 //@name test and subtest
428 
453 #define START_TEST(class_name, version) \
454  int main(int argc, char** argv) \
455  { \
456  TEST::mainInit(version, #class_name, argc, argv[0]); \
457  try {
458 
470 #define END_TEST \
471  /* global try block */ \
472  } \
473  catch (...) \
474  { \
475  TEST::printLastException(stdcout); \
476  } \
477  return TEST::endTestPostProcess(stdcout); \
478  }
479 
502 #define START_SECTION(name_of_test) \
503  TEST::test = true; \
504  TEST::newline = false; \
505  TEST::test_name = # name_of_test; \
506  TEST::test_count = 0; \
507  TEST::start_section_line = __LINE__; \
508  stdcout << "checking " << TEST::test_name << " ... " << std::flush; \
509  try \
510  { \
511  while (true) \
512  {
513 
539 #define END_SECTION \
540  break; \
541  } \
542  } \
543  catch (...) \
544  { \
545  TEST::printLastException(stdcout);\
546  } \
547  TEST::endSectionPostProcess(stdcout, __LINE__);
548 
549 
551 
571 #define TEST_EQUAL(a, b) TEST::testEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
572 
582 #define TEST_TRUE(a) TEST::testTrue(__FILE__, __LINE__, (a), (#a));
583 
593 #define TEST_FALSE(a) TEST::testFalse(__FILE__, __LINE__, (a), (#a));
594 
595 
607 #define TEST_NOT_EQUAL(a, b) TEST::testNotEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
608 
621 #define TEST_STRING_EQUAL(a, b) TEST::testStringEqual(__FILE__, __LINE__, (a), (# a), (b), (# b));
622 
637 #define TEST_FILE_EQUAL(filename, templatename) \
638  { \
639  TEST::filesEqual(__LINE__, filename, templatename, #filename, #templatename); \
640  }
641 
657 #define TEST_REAL_SIMILAR(a, b) TEST::testRealSimilar(__FILE__, __LINE__, (a), (# a), TEST::isRealType(a), writtenDigits(a), (b), (# b), TEST::isRealType(b), writtenDigits(b));
658 
674 #define TEST_STRING_SIMILAR(a, b) TEST::testStringSimilar(__FILE__, __LINE__, (a), (# a), (b), (# b));
675 
690 #define TEST_FILE_SIMILAR(a, b) \
691  { \
692  ++TEST::test_count; \
693  TEST::test_line = __LINE__; \
694  TEST::this_test = TEST::isFileSimilar((a), (b)); \
695  TEST::test = TEST::test && TEST::this_test; \
696  { \
697  TEST::initialNewline(); \
698  if (TEST::this_test) \
699  { \
700  if (TEST::verbose > 1) \
701  { \
702  stdcout << " + line " << __LINE__ \
703  << ": TEST_FILE_SIMILAR(" # a "," # b "): absolute: " \
704  << precisionWrapper(TEST::absdiff) \
705  << " (" \
706  << precisionWrapper(TEST::absdiff_max_allowed) \
707  << "), relative: " \
708  << precisionWrapper(TEST::ratio) \
709  << " (" \
710  << precisionWrapper(TEST::ratio_max_allowed) \
711  << ")\n"; \
712  stdcout << "message: \n"; \
713  stdcout << TEST::fuzzy_message; \
714  } \
715  } \
716  else \
717  { \
718  stdcout << " - line " << TEST::test_line << \
719  ": TEST_FILE_SIMILAR(" # a "," # b ") ... -\n"; \
720  stdcout << "message: \n"; \
721  stdcout << TEST::fuzzy_message; \
722  TEST::failed_lines_list.push_back(TEST::test_line); \
723  } \
724  } \
725  }
726 
739 #define TOLERANCE_RELATIVE(a) \
740  TEST::ratio_max_allowed = (a); \
741  { \
742  TEST::initialNewline(); \
743  if (TEST::verbose > 1) \
744  { \
745  stdcout << " + line " << __LINE__ << \
746  ": TOLERANCE_RELATIVE(" << TEST::ratio_max_allowed << \
747  ") (\"" # a "\")\n"; \
748  } \
749  }
750 
762 #define TOLERANCE_ABSOLUTE(a) \
763  TEST::absdiff_max_allowed = (a); \
764  { \
765  TEST::initialNewline(); \
766  if (TEST::verbose > 1) \
767  { \
768  stdcout << " + line " << __LINE__ << \
769  ": TOLERANCE_ABSOLUTE(" << TEST::absdiff_max_allowed << \
770  ") (\"" # a "\")\n"; \
771  } \
772  }
773 
779 #define WHITELIST(a) TEST::setWhitelist(__FILE__, __LINE__, (a));
780 
793 #define TEST_EXCEPTION(exception_type, command) \
794  { \
795  ++TEST::test_count; \
796  TEST::test_line = __LINE__; \
797  TEST::exception = 0; \
798  try \
799  { \
800  command; \
801  } \
802  catch (exception_type&) \
803  { \
804  TEST::exception = 1; \
805  } \
806  catch (::OpenMS::Exception::BaseException& e) \
807  { \
808  TEST::exception = 2; \
809  TEST::exception_name = e.getName(); \
810  } \
811  catch (const std::exception& e) \
812  { \
813  TEST::exception = 3; \
814  TEST::exception_name = e.what(); \
815  } \
816  catch (...) \
817  { \
818  TEST::exception = 4; \
819  } \
820  TEST::this_test = (TEST::exception == 1); \
821  TEST::test = TEST::test && TEST::this_test; \
822  { \
823  TEST::initialNewline(); \
824  switch (TEST::exception) \
825  { \
826  case 0: \
827  stdcout << " - line " << TEST::test_line << \
828  ": TEST_EXCEPTION(" # exception_type "," # command \
829  "): no exception thrown!\n"; \
830  TEST::failed_lines_list.push_back(TEST::test_line); \
831  break; \
832  case 1: \
833  if (TEST::verbose > 1) \
834  { \
835  stdcout << " + line " << TEST::test_line << \
836  ": TEST_EXCEPTION(" # exception_type "," # command \
837  "): OK\n"; \
838  } \
839  break; \
840  case 2: \
841  stdcout << " - line " << TEST::test_line << \
842  ": TEST_EXCEPTION(" # exception_type "," # command \
843  "): wrong exception thrown! \"" \
844  << TEST::exception_name << "\"\n"; \
845  TEST::failed_lines_list.push_back(TEST::test_line); \
846  break; \
847  case 3: \
848  stdcout << " - line " << TEST::test_line << \
849  ": TEST_EXCEPTION(" # exception_type "," # command \
850  "): wrong exception thrown! \"" \
851  << TEST::exception_name << "\"\n"; \
852  TEST::failed_lines_list.push_back(TEST::test_line); \
853  break; \
854  case 4: \
855  stdcout << " - line " << TEST::test_line << \
856  ": TEST_EXCEPTION(" # exception_type "," # command \
857  "): wrong exception thrown!\n"; \
858  TEST::failed_lines_list.push_back(TEST::test_line); \
859  break; \
860  } \
861  } \
862  }
863 
875 #ifdef OPENMS_ASSERTIONS
876 #define TEST_PRECONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Precondition, command);
877 #else
878 #define TEST_PRECONDITION_VIOLATED(command) STATUS("TEST_PRECONDITION_VIOLATED(" # command ") - skipped");
879 #endif
880 
892 #ifdef OPENMS_ASSERTIONS
893 #define TEST_POSTCONDITION_VIOLATED(command) TEST_EXCEPTION(Exception::Postcondition, command);
894 #else
895 #define TEST_POSTCONDITION_VIOLATED(command) STATUS("TEST_POSTCONDITION_VIOLATED(" # command ") - skipped");
896 #endif
897 
898 
915 #define TEST_EXCEPTION_WITH_MESSAGE(exception_type, command, message) \
916  { \
917  ++TEST::test_count; \
918  TEST::test_line = __LINE__; \
919  TEST::exception = 0; \
920  try \
921  { \
922  command; \
923  } \
924  catch (exception_type& et) \
925  { \
926  if (std::string(et.what()) != std::string(message)) \
927  { \
928  TEST::exception = 4; \
929  TEST::exception_message = et.what(); \
930  } \
931  else TEST::exception = 1; \
932  } \
933  catch (::OpenMS::Exception::BaseException& e) \
934  { \
935  TEST::exception = 2; \
936  TEST::exception_name = e.getName(); \
937  } \
938  catch (...) \
939  { \
940  TEST::exception = 3; \
941  } \
942  TEST::this_test = (TEST::exception == 1); \
943  TEST::test = TEST::test && TEST::this_test; \
944  \
945  { \
946  TEST::initialNewline(); \
947  switch (TEST::exception) \
948  { \
949  case 0: \
950  stdcout << " - line " << TEST::test_line << \
951  ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
952  "): no exception thrown!\n"; \
953  TEST::failed_lines_list.push_back(TEST::test_line); \
954  break; \
955  case 1: \
956  if (TEST::verbose > 1) \
957  { \
958  /* this is actually what we want to get: */ \
959  stdcout << " + line " << TEST::test_line << \
960  ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
961  "): OK\n"; \
962  } \
963  break; \
964  case 2: \
965  stdcout << " - line " << TEST::test_line << \
966  ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
967  "): wrong exception thrown! \"" << \
968  TEST::exception_name << "\"\n"; \
969  TEST::failed_lines_list.push_back(TEST::test_line); \
970  break; \
971  case 3: \
972  stdcout << " - line " << TEST::test_line << \
973  ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
974  "): wrong exception thrown!\n"; \
975  TEST::failed_lines_list.push_back(TEST::test_line); \
976  break; \
977  case 4: \
978  stdcout << " - line " << TEST::test_line << \
979  ": TEST_EXCEPTION_WITH_MESSAGE(" # exception_type "," # command ", " # message \
980  "): exception has wrong message: got '" << \
981  TEST::exception_message << \
982  "', expected '" << \
983  (message) << "'\n"; \
984  TEST::failed_lines_list.push_back(TEST::test_line); \
985  break; \
986  } \
987  } \
988  }
989 
1003 #define NEW_TMP_FILE_EXT(filename, extension) filename = TEST::createTmpFileName(__FILE__, __LINE__, extension);
1004 
1005 
1006 #define NEW_TMP_FILE(filename) filename = TEST::createTmpFileName(__FILE__, __LINE__);
1007 
1008 
1016 #define ABORT_IF(condition) \
1017  if (condition) \
1018  { \
1019  { \
1020  TEST::test_line = __LINE__; \
1021  TEST::this_test = false; \
1022  TEST::test = TEST::test && TEST::this_test; \
1023  TEST::failed_lines_list.push_back(TEST::test_line); \
1024  TEST::initialNewline(); \
1025  stdcout << " - line " << TEST::test_line << \
1026  ": ABORT_IF(" # condition "): TEST ABORTED\n"; \
1027  } \
1028  break; \
1029  }
1030 
1048 #define STATUS(message) \
1049  { \
1050  TEST::initialNewline(); \
1051  stdcout << " line " \
1052  << __LINE__ \
1053  << ": status: " \
1054  << message \
1055  << "\n"; \
1056  }
1057 
1067 #define ADD_MESSAGE(message) \
1068  TEST::add_message = message;
1069 
1079 #define NOT_TESTABLE \
1080  TEST::test_count = 1;
1081 
char16_t XMLCh
Definition: ClassTest.h:28
#define stdcout
Provide a point of redirection for testing the test macros, see ClassTest_test.cpp.
Definition: ClassTest.h:35
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:29
int Int
Signed integer type.
Definition: Types.h:72
Namespace for class tests.
Definition: ClassTest.h:44
double ratio_max
Maximum ratio of numbers observed so far, see TOLERANCE_RELATIVE.
int verbose
Verbosity level ( "-v" is 1 and "-V" is 2 )
int test_count
Counter for the number of elementary tests within the current subsection.
int endTestPostProcess(std::ostream &out)
void initialNewline()
make sure we have a newline before results from first subtest
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 endSectionPostProcess(std::ostream &out, const int line)
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:274
int test_line
Line of current elementary test.
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.
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.
bool validate(const std::vector< std::string > &file_names)
Validates the given files against the XML schema (if available)
std::string fuzzy_message
Last message from a fuzzy comparison. Written by isRealSimilar(), testStringSimilar(),...
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 ...
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 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
double absdiff_max
Maximum difference of numbers observed so far, see TOLERANCE_ABSOLUTE.
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 newline
(Flags whether a new line is in place, depending on context and verbosity setting....
bool test
Status of the current subsection.
double absdiff_max_allowed
Maximum absolute difference of numbers allowed, see TOLERANCE_ABSOLUTE.
const char * version_string
Version string supplied with START_TEST.
std::ifstream infile
Questionable file tested by TEST_FILE_EQUAL.
void testTrue(const char *, int line, const bool expression_1, const char *expression_1_stringified)
Definition: ClassTest.h:312
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.
void testFalse(const char *, int line, const bool expression_1, const char *expression_1_stringified)
Definition: ClassTest.h:335
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 removeTempFiles()
removed all temporary files created with the NEW_TMP_FILE macro
double ratio
Recent ratio of numbers, see TOLERANCE_RELATIVE.
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.
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:360
bool this_test
Status of last elementary test.
std::ifstream templatefile
Template (correct) file used by TEST_FILE_EQUAL.
double ratio_max_allowed
Maximum ratio of numbers allowed, see TOLERANCE_RELATIVE.
void setWhitelist(const char *const, const int line, const std::string &whitelist)
set the whitelist_
bool isRealType(float)
This overload returns true; float is a floating point type.
Definition: ClassTest.h:59
bool equal_files
(A variable used by TEST_FILE_EQUAL)
int start_section_line
Line where current subsection started.
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)
void printLastException(std::ostream &out)
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
bool isRealSimilar(long double number_1, long double number_2)
used by testRealSimilar()
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19