102 bool check(
const bool,
const std::string& str =
"");
109 bool check_if_equal(
const std::string& a,
const std::string& b,
const std::string& str =
"");
110 bool check_if_equal(
const double a,
const double b,
const std::string& str =
"");
112 bool check_if_equal(
const short a,
const short b,
const std::string& str =
"");
113 bool check_if_equal(
const unsigned short a,
const unsigned short b,
const std::string& str =
"");
114 bool check_if_equal(
const int a,
const int b,
const std::string& str =
"");
115 bool check_if_equal(
const unsigned int a,
const unsigned int b,
const std::string& str =
"");
116 bool check_if_equal(
const long a,
const long b,
const std::string& str =
"");
117 bool check_if_equal(
const unsigned long a,
const unsigned long b,
const std::string& str =
"");
118#ifdef BOOST_HAS_LONG_LONG
120 bool check_if_equal(
const long long a,
const long long b,
const std::string& str =
"");
121 bool check_if_equal(
const unsigned long long a,
const unsigned long long b,
const std::string& str =
"");
123 bool check_if_equal(
const Bin& a,
const Bin& b,
const std::string& str =
"")
130 return this->check_if_equal_generic(a, b, str);
136 bool check_if_equal(
const std::complex<T> a,
const std::complex<T> b,
const std::string& str =
"")
138 return check_if_equal(a.real(), b.real(), str) && check_if_equal(a.imag(), b.imag(), str);
146 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
152 if (!check_if_equal(t1[i], t2[i], str))
154 std::cerr <<
"(at VectorWithOffset<" <<
typeid(T).name() <<
"> first mismatch at index " << i <<
")\n";
163 bool check_if_equal(
const std::vector<T>& t1,
const std::vector<T>& t2,
const std::string& str =
"")
165 if (t1.size() != t2.size())
167 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
171 bool all_equal =
true;
172 for (
unsigned int i = 0; i < t1.size(); i++)
174 if (!check_if_equal(t1[i], t2[i], str))
176 std::cerr <<
"(at vector<" <<
typeid(T).name() <<
"> mismatch at index " << i <<
")\n";
191 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
192 return everything_ok =
false;
198 template <
int num_dimensions,
class coordT>
201 const std::string& str =
"")
205 std::cerr <<
"Error : Unequal Coordinate value are " << a <<
" and " << b <<
". " << str << std::endl;
219 bool check_if_zero(
const double a,
const std::string& str =
"");
220 bool check_if_zero(
const short a,
const std::string& str =
"");
221 bool check_if_zero(
const unsigned short a,
const std::string& str =
"");
222 bool check_if_zero(
const int a,
const std::string& str =
"");
223 bool check_if_zero(
const unsigned int a,
const std::string& str =
"");
224 bool check_if_zero(
const long a,
const std::string& str =
"");
225 bool check_if_zero(
const unsigned long a,
const std::string& str =
"");
226#ifdef BOOST_HAS_LONG_LONG
227 bool check_if_zero(
const long long a,
const std::string& str =
"");
228 bool check_if_zero(
const unsigned long long a,
const std::string& str =
"");
236 for (
int i = t.get_min_index(); i <= t.get_max_index(); i++)
240 std::cerr <<
"(at VectorWithOffset<" <<
typeid(T).name() <<
"> first mismatch at index " << i <<
")\n";
248 template <
int num_dimensions,
class coordT>
253 std::cerr <<
"Error : Coordinate value is " << a <<
" expected 0s. " << str << std::endl;
263 template <
class T1,
class T2>
264 inline bool check_if_less(T1 a, T2 b,
const std::string& str =
"");
278 std::cerr <<
"Error : unequal values are " << a <<
" and " << b <<
". " << str << std::endl;
290 if ((a !=
static_cast<T
>(0)))
292 std::cerr <<
"Error : 0 value is " << a <<
" ." << str << std::endl;
312#if defined(_DEBUG) && defined(__MSL__)
313 DebugNewReportLeaks();
317 std::cerr <<
"\nAll tests ok !\n\n" << std::endl;
319 std::cerr <<
"\nEnd of tests. Please correct errors !\n\n" << std::endl;
351 std::cerr <<
"Error. " << str << std::endl;
358RunTests::check_if_equal(
const std::string& a,
const std::string& b,
const std::string& str)
378RunTests::check_if_equal(
const double a,
const double b,
const std::string& str)
380 const double diff = fabs(b - a);
384 const double largest = (std::max(fabs(b), fabs(a)));
388 std::cerr <<
"Error : unequal values are " << a <<
" and " << b <<
". " << str << std::endl;
397RunTests::check_if_equal(
const short a,
const short b,
const std::string& str)
402RunTests::check_if_equal(
const unsigned short a,
const unsigned short b,
const std::string& str)
407RunTests::check_if_equal(
const int a,
const int b,
const std::string& str)
412RunTests::check_if_equal(
const unsigned int a,
const unsigned int b,
const std::string& str)
417RunTests::check_if_equal(
const long a,
const long b,
const std::string& str)
422RunTests::check_if_equal(
const unsigned long a,
const unsigned long b,
const std::string& str)
426#ifdef BOOST_HAS_LONG_LONG
428RunTests::check_if_equal(
const long long a,
const long long b,
const std::string& str)
433RunTests::check_if_equal(
const unsigned long long a,
const unsigned long long b,
const std::string& str)
442 if (*t1.get_proj_data_info_sptr() != *t2.get_proj_data_info_sptr())
444 std::cerr <<
"Error: unequal proj_data_info. " << str << std::endl;
448 for (
auto i1 = t1.begin(), i2 = t2.begin(); i1 != t1.end(); ++i1, ++i2)
450 if (!check_if_equal(*i1, *i2, str))
488#ifdef BOOST_HAS_LONG_LONG
507 std::cerr <<
"Error : 0 value is " << a <<
" ." << str << std::endl;
515template <
class T1,
class T2>
521 std::cerr <<
"Error : " << a <<
" is larger than " << b <<
", " << str << std::endl;
This file declares class stir::BasicCoordinate and some functions acting on stir::BasicCoordinate obj...
Declaration of class stir::Bin.
Declaration of class stir::DetectionPosition.
This file defines the stir::IndexRange class.
Declaration of class stir::ProjDataInMemory.
defines the stir::VectorWithOffset class
class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordi...
Definition BasicCoordinate.h:57
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
A class for storing coordinates of a detection.
Definition DetectionPosition.h:61
This class defines ranges which can be 'irregular'.
Definition IndexRange.h:69
A class which reads/writes projection data from/to memory.
Definition ProjDataInMemory.h:39
double get_tolerance() const
Get value used in floating point comparisons (see check_* functions)
Definition RunTests.h:341
bool check_if_equal(const VectorWithOffset< T > &t1, const VectorWithOffset< T > &t2, const std::string &str="")
check equality by comparing ranges and calling check_if_equal on all elements
Definition RunTests.h:142
bool check_if_less(T1 a, T2 b, const std::string &str="")
check if a<b
Definition RunTests.h:517
bool everything_ok
variable storing current status
Definition RunTests.h:270
bool check_if_equal(const BasicCoordinate< num_dimensions, coordT > &a, const BasicCoordinate< num_dimensions, coordT > &b, const std::string &str="")
check equality by comparing norm(a-b) with tolerance
Definition RunTests.h:199
bool check(const bool, const std::string &str="")
Tests if true, str can be used to tell what you are testing.
Definition RunTests.h:347
bool is_everything_ok() const
Returns if all checks were fine upto now.
Definition RunTests.h:323
RunTests(const double tolerance=1E-4)
Default constructor.
Definition RunTests.h:305
double tolerance
tolerance for comparisons with real values
Definition RunTests.h:268
bool check_if_equal(const std::vector< T > &t1, const std::vector< T > &t2, const std::string &str="")
check equality by comparing size and calling check_if_equal on all elements
Definition RunTests.h:163
int main_return_value() const
Handy return value for a main() function.
Definition RunTests.h:329
bool check_if_equal(const std::complex< T > a, const std::complex< T > b, const std::string &str="")
check equality by calling check_if_equal on real and imaginary parts
Definition RunTests.h:136
bool check_if_equal_generic(const T &a, const T &b, const std::string &str)
function that is called by some check_if_equal implementations. It just uses operator!...
Definition RunTests.h:274
bool check_if_zero_generic(T a, const std::string &str)
function that is called by some check_if_zero implementations. It just uses operator!...
Definition RunTests.h:288
virtual ~RunTests()
Destructor, outputs a diagnostic message.
Definition RunTests.h:310
bool check_if_zero(const double a, const std::string &str="")
Definition RunTests.h:503
bool check_if_zero(const VectorWithOffset< T > &t, const std::string &str="")
use check_if_zero on all elements
Definition RunTests.h:234
void set_tolerance(const double tolerance)
Set value used in floating point comparisons (see check_* functions)
Definition RunTests.h:335
bool check_if_zero(const BasicCoordinate< num_dimensions, coordT > &a, const std::string &str="")
compare norm with tolerance
Definition RunTests.h:249
virtual void run_tests()=0
Function (to be overloaded) which does the actual tests.
A templated class for vectors, but with indices starting not from 0.
Definition VectorWithOffset.h:65
int get_max_index() const
get value of last valid index
Definition VectorWithOffset.inl:131
int get_min_index() const
get value of first valid index
Definition VectorWithOffset.inl:124
double norm(const BasicCoordinate< num_dimensions, coordT > &p1)
compute sqrt(inner_product(p1,p1))
Definition BasicCoordinate.inl:426
Input/output of basic vector-like types to/from streams.