test_mgr.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2020, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_TEST_MGR_H
24 #define O2SCL_TEST_MGR_H
25 
26 /** \file test_mgr.h
27  \brief File defining \ref o2scl::test_mgr
28 */
29 
30 #include <string>
31 
32 #ifdef O2SCL_LD_TYPES
33 #include <boost/multiprecision/number.hpp>
34 #endif
35 
36 #include <o2scl/string_conv.h>
37 #include <o2scl/misc.h>
38 #include <o2scl/table_units.h>
39 
40 #include <gsl/gsl_vector.h>
41 #include <gsl/gsl_sys.h>
42 #include <gsl/gsl_matrix.h>
43 
44 #ifndef DOXYGEN_NO_O2NS
45 namespace o2scl {
46 #endif
47 
48  /** \brief A class to manage testing and record success and failure
49  */
50  class test_mgr {
51 
52  protected:
53 
54 #ifndef DOXYGEN_INTERNAL
55 
56  /// The number of tests performed
57  int ntests;
58 
59  /// The output level
61 
62  /// A helper function for processing tests
63  void process_test(bool ret, std::string d2, std::string description);
64 
65  /// True if all tests have passed
66  bool success;
67 
68  /// The description of the last failed test
69  std::string last_fail;
70 
71 #endif
72 
73  public:
74 
75  /// Create a \ref test_mgr object
76  test_mgr(bool success_l=true, std::string last_fail_l="",
77  int ntests_l=0, int output_level_l=1) {
78  success=success_l;
79  last_fail=last_fail_l;
80  ntests=ntests_l;
81  output_level=output_level_l;
82  }
83 
84  /** \brief Provide a report of all tests so far.
85 
86  This function reports on whether or not all tests have passed
87  according to the current output level. It returns true if all
88  tests have passed and false if at least one test failed.
89  */
90  bool report() const;
91 
92  /// \name Individual get and set methods
93  //@{
94  /// Return true if all tests have succeeded
95  bool get_success() const {
96  return success;
97  }
98 
99  /// Return the last failure description
100  std::string get_last_fail() const {
101  return last_fail;
102  }
103 
104  /// Return the output level
105  int get_output_level() const {
106  return output_level;
107  }
108 
109  /// Returns the description of the last test that failed.
110  std::string get_last_fail() { return last_fail; };
111 
112  /** \brief Set the output level
113 
114  Possible values:
115  - 0 = No output
116  - 1 = Output only tests that fail
117  - 2 = Output all tests
118  */
119  void set_output_level(int l) { output_level=l; };
120 
121  /// Return the number of tests performed so far
122  int get_ntests() const { return ntests; };
123  //@}
124 
125  /// \name Main testing methods
126  //@{
127  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
128  <\mathrm{abs\_error}\f$
129  */
130  template<class data_t=double>
131  bool test_abs(data_t result, data_t expected, data_t abs_error,
132  std::string description) {
133  bool ret;
134  if (std::isnan(expected)) {
135  ret=(std::isnan(expected)==std::isnan(result));
136  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
137  "\n "+description;
138  } else if (std::isinf(expected)) {
139  ret=(std::isinf(expected)==std::isinf(result));
140  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
141  "\n "+description;
142  } else {
143  ret=(std::abs(expected-result)<abs_error);
144  if (ret) {
145  description=dtos<data_t>(result)+" vs. "+
146  dtos<data_t>(expected)+" : "
147  +dtos<data_t>(std::abs(expected-result))+" < "+
148  dtos<data_t>(abs_error)+
149  "\n "+description;
150  } else {
151  description=dtos<data_t>(result)+" vs. "+
152  dtos<data_t>(expected)+" : "
153  +dtos<data_t>(std::abs(expected-result))+" > "+
154  dtos<data_t>(abs_error)+
155  "\n "+description;
156  }
157  }
158 
159  process_test(ret,"absolute",description);
160 
161  return ret;
162  }
163 
164  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
165  \mathrm{expected}<\mathrm{rel\_error}\f$
166  */
167  template<class data_t=double>
168  bool test_rel(data_t result, data_t expected, data_t rel_error,
169  std::string description) {
170  bool ret;
171  if (std::isnan(expected)) {
172  ret=(std::isnan(expected)==std::isnan(result));
173  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
174  "\n "+description;
175  } else if (std::isinf(expected)) {
176  ret=(std::isinf(expected)==std::isinf(result));
177  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
178  "\n "+description;
179  } else if (expected==0.0) {
180  ret=test_abs<data_t>(result,expected,rel_error,description);
181  return ret;
182  } else {
183  double obs_err=std::abs(expected-result)/std::abs(expected);
184  ret=(obs_err<rel_error);
185  if (ret) {
186  description=dtos<data_t>(result)+" vs. "+dtos<data_t>(expected)+
187  " : "+dtos<data_t>(obs_err)+
188  " < "+dtos<data_t>(rel_error)+"\n "+description;
189  } else {
190  description=dtos<data_t>(result)+" vs. "+dtos<data_t>(expected)+
191  " : "+dtos<data_t>(obs_err)+
192  " > "+dtos<data_t>(rel_error)+"\n "+description;
193  }
194  }
195 
196  process_test(ret,"relative",description);
197  return ret;
198  }
199 
200 #if defined(O2SCL_LD_TYPES) || defined(DOXYGEN)
201 
202  /** \brief Testing functions for \c boost::multiprecision numbers
203 
204  This function is similar to \ref test_abs(), but replaces
205  \c isnan and related functions with boost versions from
206  \c boost::multiprecision::number .
207  */
208  template<class data_t=double>
209  bool test_abs_boost(data_t result, data_t expected, data_t abs_error,
210  std::string description) {
211  bool ret;
212  if (boost::multiprecision::isnan(expected)) {
213  ret=(boost::multiprecision::isnan(expected)==
214  boost::multiprecision::isnan(result));
215  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
216  "\n "+description;
217  } else if (boost::multiprecision::isinf(expected)) {
218  ret=(boost::multiprecision::isinf(expected)==
219  boost::multiprecision::isinf(result));
220  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
221  "\n "+description;
222  } else {
223  ret=(boost::multiprecision::abs(expected-result)<abs_error);
224  if (ret) {
225  description=dtos<data_t>(result)+" vs. "+
226  dtos<data_t>(expected)+" : "
227  +dtos<data_t>(boost::multiprecision::abs(expected-result))+" < "+
228  dtos<data_t>(abs_error)+
229  "\n "+description;
230  } else {
231  description=dtos<data_t>(result)+" vs. "+
232  dtos<data_t>(expected)+" : "
233  +dtos<data_t>(boost::multiprecision::abs(expected-result))+" > "+
234  dtos<data_t>(abs_error)+
235  "\n "+description;
236  }
237  }
238 
239  process_test(ret,"absolute",description);
240 
241  return ret;
242  }
243 
244  /** \brief Testing functions for \c boost::multiprecision numbers
245 
246  This function is similar to \ref test_abs(), but replaces
247  \c isnan and related functions with boost versions from
248  \c boost::multiprecision::number .
249  */
250  template<class data_t=double>
251  bool test_rel_boost(data_t result, data_t expected, data_t rel_error,
252  std::string description) {
253  bool ret;
254  if (boost::multiprecision::isnan(expected)) {
255  ret=(boost::multiprecision::isnan(expected)==
256  boost::multiprecision::isnan(result));
257  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
258  "\n "+description;
259  } else if (boost::multiprecision::isinf(expected)) {
260  ret=(boost::multiprecision::isinf(expected)==
261  boost::multiprecision::isinf(result));
262  description=dtos<data_t>(result)+" vs. "+ dtos<data_t>(expected)+
263  "\n "+description;
264  } else if (expected==0.0) {
265  ret=test_abs_boost<data_t>(result,expected,rel_error,description);
266  return ret;
267  } else {
268  double obs_err=boost::multiprecision::abs(expected-result)/boost::multiprecision::abs(expected);
269  ret=(obs_err<rel_error);
270  if (ret) {
271  description=dtos<data_t>(result)+" vs. "+dtos<data_t>(expected)+
272  " : "+dtos<data_t>(obs_err)+
273  " < "+dtos<data_t>(rel_error)+"\n "+description;
274  } else {
275  description=dtos<data_t>(result)+" vs. "+dtos<data_t>(expected)+
276  " : "+dtos<data_t>(obs_err)+
277  " > "+dtos<data_t>(rel_error)+"\n "+description;
278  }
279  }
280 
281  process_test(ret,"relative",description);
282  return ret;
283  }
284 
285 #endif
286 
287  /** \brief Test for \f$1/\mathrm{factor} < \mathrm{result/expected}
288  < \mathrm{factor}\f$
289  */
290  template<class data_t>
291  bool test_fact(data_t result, data_t expected, data_t factor,
292  std::string description) {
293  bool ret;
294  double ratio;
295  if (std::isnan(expected)) {
296  ret=(std::isnan(expected)==std::isnan(result));
297  } else if (std::isinf(expected)) {
298  ret=(std::isinf(expected)==std::isinf(result));
299  } else {
300  ratio=expected/result;
301  ret=(ratio<factor && ratio>1.0/factor);
302  }
303 
304  description= dtos(result)+" vs. "+ dtos(expected)+"\n "+
305  description;
306  process_test(ret,"factor",description);
307 
308  return ret;
309  }
310 
311  /// Test for \f$\mathrm{result}=\mathrm{expected}\f$
312  bool test_str(std::string result, std::string expected,
313  std::string description);
314 
315  /// Test for \f$\mathrm{result}=\mathrm{expected}\f$
316  bool test_gen(bool value, std::string description);
317  //@}
318 
319  /// \name Vector testing methods
320  //@{
321  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
322  \mathrm{expected}<\mathrm{rel\_error}\f$ over each element
323  of an array
324  */
325  template<class vec_t, class vec2_t, class data_t>
326  bool test_rel_vec(int nv, const vec_t &result, const vec2_t &expected,
327  data_t rel_error, std::string description) {
328  bool ret=true;
329  double max=0.0;
330  int i;
331 
332  for(i=0;i<nv;i++) {
333  if (std::isnan(expected[i])) {
334  ret=(ret && (std::isnan(expected[i])==std::isnan(result[i])));
335  } else if (std::isinf(expected[i])) {
336  ret=(ret && (std::isinf(expected[i])==std::isinf(result[i])));
337  } else if (expected[i]==0.0) {
338  ret=(ret && test_abs(result[i],expected[i],rel_error,description));
339  if (std::abs(result[i]-expected[i])>max) {
340  max=std::abs(result[i]-expected[i]);
341  }
342  } else {
343  ret=(ret && ((std::abs(expected[i]-result[i]))/
344  std::abs(expected[i])<rel_error));
345  if (std::abs(expected[i]-result[i])/std::abs(expected[i])>max) {
346  max=std::abs(expected[i]-result[i])/std::abs(expected[i]);
347  }
348  }
349  }
350 
351  description=((std::string)"max=")+o2scl::dtos(max)+
352  "\n "+description;
353  process_test(ret,"relative array",description);
354 
355  return ret;
356  }
357 
358  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
359  <\mathrm{abs\_error}\f$ over each element
360  of an array
361  */
362  template<class vec_t, class vec2_t, class data_t>
363  bool test_abs_vec(int nv, const vec_t &result, const vec2_t &expected,
364  data_t abs_error, std::string description) {
365  bool ret=true;
366  int i;
367 
368  for(i=0;i<nv;i++) {
369  if (std::isnan(expected[i])) {
370  ret=(ret && (std::isnan(expected[i])==std::isnan(result[i])));
371  } else if (std::isinf(expected[i])) {
372  ret=(ret && (std::isinf(expected[i])==std::isinf(result[i])));
373  } else {
374  ret=(ret && (std::abs(expected[i]-result[i])<abs_error));
375  }
376  }
377 
378  description="\n "+description;
379  process_test(ret,"absolute array",description);
380 
381  return ret;
382  }
383 
384  /** \brief Test for \f$ 1/factor < result/expected < factor \f$
385  over each element of an array
386  */
387  template<class vec_t, class vec2_t, class data_t>
388  bool test_fact_vec(int nv, const vec_t &result, const vec2_t &expected,
389  data_t factor, std::string description) {
390  bool ret=true;
391  int i;
392  double ratio;
393 
394  for(i=0;i<nv;i++) {
395  if (std::isnan(expected[i])) {
396  ret=(ret && (std::isnan(expected[i])==std::isnan(result[i])));
397  } else if (std::isinf(expected[i])) {
398  ret=(ret && (std::isinf(expected[i])==std::isinf(result[i])));
399  } else {
400  ratio=expected[i]/result[i];
401  ret=(ret && (ratio<factor && ratio>1.0/factor));
402  }
403  }
404 
405  description="\n "+description;
406  process_test(ret,"factor array",description);
407 
408  return ret;
409  }
410 
411  /// Test for equality of a generic array
412  template<class vec_t>
413  bool test_gen_vec(int nv, const vec_t &result, const vec_t &expected,
414  std::string description) {
415  bool ret=true;
416  int i;
417 
418  for(i=0;i<nv;i++) {
419  ret=(ret && (result[i]==expected[i]));
420  }
421 
422  description="\n "+description;
423  process_test(ret,"generic array",description);
424 
425  return ret;
426  }
427  //@}
428 
429  /// \name Matrix testing methods
430  //@{
431  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
432  \mathrm{expected}<\mathrm{rel\_error}\f$ over each element
433  in a matrix
434  */
435  template<class mat_t, class mat2_t, class data_t>
436  bool test_rel_mat(int nr, int nc, const mat_t &result,
437  const mat2_t &expected,
438  data_t rel_error, std::string description) {
439  bool ret=true;
440  double max=0.0;
441  int i, j;
442 
443  for(i=0;i<nr;i++) {
444  for(j=0;j<nc;j++) {
445  if (std::isnan(expected(i,j))) {
446  ret=(ret && (std::isnan(expected(i,j))==
447  std::isnan(result(i,j))));
448  } else if (std::isinf(expected(i,j))) {
449  ret=(ret && (std::isinf(expected(i,j))==
450  std::isinf(result(i,j))));
451  } else if (expected(i,j)==0.0) {
452  ret=(ret && test_abs(result(i,j),expected(i,j),rel_error,
453  description));
454  if (std::abs(result(i,j)-expected(i,j))>max) {
455  max=std::abs(result(i,j)-expected(i,j));
456  }
457  } else {
458  ret=(ret && ((std::abs(expected(i,j)-result(i,j)))/
459  std::abs(expected(i,j))<rel_error));
460  if (std::abs(expected(i,j)-result(i,j))/
461  std::abs(expected(i,j))>max) {
462  max=std::abs(expected(i,j)-result(i,j))/
463  std::abs(expected(i,j));
464  }
465  }
466  }
467  }
468 
469  description=((std::string)"max=")+o2scl::dtos(max)+
470  "\n "+description;
471  process_test(ret,"relative matrix",description);
472 
473  return ret;
474 
475  }
476 
477  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}|/
478  \mathrm{expected}<\mathrm{rel\_error}\f$ over each element
479  in a matrix larger than a specified tolerance
480  */
481  template<class mat_t, class mat2_t, class data_t>
482  bool test_rel_nonzero_mat(int nr, int nc, const mat_t &result,
483  const mat2_t &expected,
484  data_t error, data_t zero_tol,
485  std::string description) {
486  bool ret=true;
487  double max=0.0;
488  int i, j;
489 
490  for(i=0;i<nr;i++) {
491  for(j=0;j<nc;j++) {
492  if (std::isnan(expected(i,j))) {
493  ret=(ret && (std::isnan(expected(i,j))==
494  std::isnan(result(i,j))));
495  } else if (std::isinf(expected(i,j))) {
496  ret=(ret && (std::isinf(expected(i,j))==
497  std::isinf(result(i,j))));
498  } else if (expected(i,j)<zero_tol) {
499  ret=(ret && test_abs(result(i,j),expected(i,j),error,
500  description));
501  if (std::abs(result(i,j)-expected(i,j))>max) {
502  max=std::abs(result(i,j)-expected(i,j));
503  }
504  } else {
505  ret=(ret && ((std::abs(expected(i,j)-result(i,j)))/
506  std::abs(expected(i,j))<error));
507  if (std::abs(expected(i,j)-result(i,j))/
508  std::abs(expected(i,j))>max) {
509  max=std::abs(expected(i,j)-result(i,j))/
510  std::abs(expected(i,j));
511  }
512  }
513  }
514  }
515 
516  description=((std::string)"max=")+o2scl::dtos(max)+
517  "\n "+description;
518  process_test(ret,"rel_nonzero matrix",description);
519 
520  return ret;
521 
522  }
523 
524  /** \brief Test for \f$|\mathrm{result}-\mathrm{expected}| <
525  \mathrm{abs\_error} \f$ over each element in a matrix
526  */
527  template<class mat_t, class mat2_t, class data_t>
528  bool test_abs_mat(int nr, int nc, const mat_t &result,
529  const mat2_t &expected, data_t abs_error,
530  std::string description) {
531 
532  bool ret=true;
533  double max=0.0;
534  int i, j;
535 
536  for(i=0;i<nr;i++) {
537  for(j=0;j<nc;j++) {
538  if (std::isnan(expected(i,j))) {
539  ret=(ret && (std::isnan(expected(i,j))==
540  std::isnan(result(i,j))));
541  } else if (std::isinf(expected(i,j))) {
542  ret=(ret && (std::isinf(expected(i,j))==
543  std::isinf(result(i,j))));
544  } else if (expected(i,j)==0.0) {
545  ret=(ret && test_abs(result(i,j),expected(i,j),abs_error,
546  description));
547  if (std::abs(result(i,j)-expected(i,j))>max) {
548  max=std::abs(result(i,j)-expected(i,j));
549  }
550  } else {
551  ret=(ret && ((std::abs(expected(i,j)-result(i,j)))<abs_error));
552  if (std::abs(expected(i,j)-result(i,j))>max) {
553  max=std::abs(expected(i,j)-result(i,j));
554  }
555  }
556  }
557  }
558 
559  description=((std::string)"max=")+o2scl::dtos(max)+
560  "\n "+description;
561  process_test(ret,"absolute matrix",description);
562 
563  return ret;
564 
565  }
566  //@}
567 
568  /** \brief Compare entries in \c expected to see if they match
569  those in table \c result.
570 
571  If the numbers in the \c expected table have an absolute value
572  less than \c zero_tol, then the absolute value of the
573  difference is used for the comparison. Otherwise, the absolute
574  value of the relative difference is used to make the
575  comparison.
576  */
577  template<class vec_t, class data_t>
579  const table_units<vec_t> &expected,
580  data_t error, data_t zero_tol,
581  std::string description) {
582  bool ret=true;
583  int i, j;
584  int nr=result.get_nlines();
585  int nc=result.get_ncolumns();
586  std::vector<double> max(nc);
587 
588  for(i=0;i<nc;i++) {
589  std::string col_name=expected.get_column_name(i);
590  for(j=0;j<nr;j++) {
591  std::string desc1=description+" col: "+col_name+" row: "+
592  o2scl::itos(j);
593  if (std::isnan(expected.get(i,j))) {
594  bool ret1=test_gen(std::isnan(expected.get(i,j))==
595  std::isnan(result.get(i,j)),desc1);
596  ret=(ret && ret1);
597  } else if (std::isinf(expected.get(i,j))) {
598  bool ret1=test_gen(std::isinf(expected.get(i,j))==
599  std::isinf(result.get(i,j)),desc1);
600  ret=(ret && ret1);
601  } else if (expected.get(i,j)<zero_tol) {
602  bool ret1=test_abs(result.get(i,j),expected.get(i,j),error,
603  desc1);
604  if (std::abs(result.get(i,j)-expected.get(i,j))>max[i]) {
605  max[i]=std::abs(result.get(i,j)-expected.get(i,j));
606  }
607  } else {
608  bool ret1=test_rel(result.get(i,j),expected.get(i,j),error,
609  desc1);
610  ret=(ret && ret1);
611  if (std::abs(expected.get(i,j)-result.get(i,j))/
612  std::abs(expected.get(i,j))>max[i]) {
613  max[i]=std::abs(expected.get(i,j)-result.get(i,j))/
614  std::abs(expected.get(i,j));
615  }
616  }
617  }
618  }
619 
620  if ((output_level>=1 && ret==false) || output_level>=2) {
621  for(i=0;i<nc;i++) {
622  std::cout << "Max for " << expected.get_column_name(i) << " is "
623  << max[i] << std::endl;
624  }
625  }
626  process_test(ret,"rel_nonzero table",description);
627 
628  return ret;
629 
630  }
631 
632  /** \brief Add two test_mgr objects (if either failed, the sum fails)
633 
634  The output level is set to the maximum value of left and
635  right operand and the number of tests is set equal to
636  the sum. The last failure descriptions of both operands
637  are appended with a <tt>operator+()</tt> prefix, or blank
638  if there were no failures from either.
639  */
640  friend const test_mgr operator+(const test_mgr& left,
641  const test_mgr& right);
642 
643  };
644 
645 #ifndef DOXYGEN_NO_O2NS
646 }
647 #endif
648 
649 #endif
o2scl::test_mgr::output_level
int output_level
The output level.
Definition: test_mgr.h:60
o2scl::test_mgr::test_rel_boost
bool test_rel_boost(data_t result, data_t expected, data_t rel_error, std::string description)
Testing functions for boost::multiprecision numbers.
Definition: test_mgr.h:251
o2scl::test_mgr::test_abs_mat
bool test_abs_mat(int nr, int nc, const mat_t &result, const mat2_t &expected, data_t abs_error, std::string description)
Test for over each element in a matrix.
Definition: test_mgr.h:528
o2scl::test_mgr::test_str
bool test_str(std::string result, std::string expected, std::string description)
Test for .
o2scl::test_mgr::get_success
bool get_success() const
Return true if all tests have succeeded.
Definition: test_mgr.h:95
o2scl::dtos
std::string dtos(const fp_t &x, int prec=6, bool auto_prec=false)
Convert a double to a string.
Definition: string_conv.h:77
o2scl::test_mgr::test_gen
bool test_gen(bool value, std::string description)
Test for .
o2scl::test_mgr::test_rel_nonzero_mat
bool test_rel_nonzero_mat(int nr, int nc, const mat_t &result, const mat2_t &expected, data_t error, data_t zero_tol, std::string description)
Test for over each element in a matrix larger than a specified tolerance.
Definition: test_mgr.h:482
o2scl
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Definition: anneal.h:42
o2scl::test_mgr::test_fact
bool test_fact(data_t result, data_t expected, data_t factor, std::string description)
Test for .
Definition: test_mgr.h:291
o2scl::test_mgr::report
bool report() const
Provide a report of all tests so far.
o2scl::test_mgr::get_last_fail
std::string get_last_fail()
Returns the description of the last test that failed.
Definition: test_mgr.h:110
o2scl::test_mgr::test_gen_vec
bool test_gen_vec(int nv, const vec_t &result, const vec_t &expected, std::string description)
Test for equality of a generic array.
Definition: test_mgr.h:413
o2scl::test_mgr::test_abs_boost
bool test_abs_boost(data_t result, data_t expected, data_t abs_error, std::string description)
Testing functions for boost::multiprecision numbers.
Definition: test_mgr.h:209
o2scl::test_mgr::last_fail
std::string last_fail
The description of the last failed test.
Definition: test_mgr.h:69
o2scl::test_mgr::test_rel_mat
bool test_rel_mat(int nr, int nc, const mat_t &result, const mat2_t &expected, data_t rel_error, std::string description)
Test for over each element in a matrix.
Definition: test_mgr.h:436
o2scl::table_units
Data table table class with units.
Definition: table_units.h:42
o2scl::test_mgr::get_last_fail
std::string get_last_fail() const
Return the last failure description.
Definition: test_mgr.h:100
o2scl::test_mgr::test_mgr
test_mgr(bool success_l=true, std::string last_fail_l="", int ntests_l=0, int output_level_l=1)
Create a test_mgr object.
Definition: test_mgr.h:76
o2scl::test_mgr::test_rel
bool test_rel(data_t result, data_t expected, data_t rel_error, std::string description)
Test for .
Definition: test_mgr.h:168
o2scl::test_mgr::test_rel_nonzero_table
bool test_rel_nonzero_table(const table_units< vec_t > &result, const table_units< vec_t > &expected, data_t error, data_t zero_tol, std::string description)
Compare entries in expected to see if they match those in table result.
Definition: test_mgr.h:578
o2scl::test_mgr
A class to manage testing and record success and failure.
Definition: test_mgr.h:50
o2scl::test_mgr::test_rel_vec
bool test_rel_vec(int nv, const vec_t &result, const vec2_t &expected, data_t rel_error, std::string description)
Test for over each element of an array.
Definition: test_mgr.h:326
o2scl::itos
std::string itos(int x)
Convert an integer to a string.
o2scl::test_mgr::get_output_level
int get_output_level() const
Return the output level.
Definition: test_mgr.h:105
o2scl::test_mgr::set_output_level
void set_output_level(int l)
Set the output level.
Definition: test_mgr.h:119
o2scl::test_mgr::operator+
const friend test_mgr operator+(const test_mgr &left, const test_mgr &right)
Add two test_mgr objects (if either failed, the sum fails)
o2scl::test_mgr::test_abs
bool test_abs(data_t result, data_t expected, data_t abs_error, std::string description)
Test for .
Definition: test_mgr.h:131
o2scl::test_mgr::test_fact_vec
bool test_fact_vec(int nv, const vec_t &result, const vec2_t &expected, data_t factor, std::string description)
Test for over each element of an array.
Definition: test_mgr.h:388
o2scl::test_mgr::success
bool success
True if all tests have passed.
Definition: test_mgr.h:66
o2scl::test_mgr::ntests
int ntests
The number of tests performed.
Definition: test_mgr.h:57
o2scl::test_mgr::test_abs_vec
bool test_abs_vec(int nv, const vec_t &result, const vec2_t &expected, data_t abs_error, std::string description)
Test for over each element of an array.
Definition: test_mgr.h:363
o2scl::test_mgr::process_test
void process_test(bool ret, std::string d2, std::string description)
A helper function for processing tests.
o2scl::test_mgr::get_ntests
int get_ntests() const
Return the number of tests performed so far.
Definition: test_mgr.h:122

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).