104 bool check(
const bool,
const std::string& str =
"");
111 bool check_if_equal(
const std::string& a,
const std::string& b,
const std::string& str =
"");
112 bool check_if_equal(
const double a,
const double b,
const std::string& str =
"");
114 bool check_if_equal(
const short a,
const short b,
const std::string& str =
"");
115 bool check_if_equal(
const unsigned short a,
const unsigned short b,
const std::string& str =
"");
116 bool check_if_equal(
const int a,
const int b,
const std::string& str =
"");
117 bool check_if_equal(
const unsigned int a,
const unsigned int b,
const std::string& str =
"");
118 bool check_if_equal(
const long a,
const long b,
const std::string& str =
"");
119 bool check_if_equal(
const unsigned long a,
const unsigned long b,
const std::string& str =
"");
120#ifdef BOOST_HAS_LONG_LONG
122 bool check_if_equal(
const long long a,
const long long b,
const std::string& str =
"");
123 bool check_if_equal(
const unsigned long long a,
const unsigned long long b,
const std::string& str =
"");
125 bool check_if_equal(
const Bin& a,
const Bin& b,
const std::string& str =
"")
132 return this->check_if_equal_generic(a, b, str);
135 bool check_if_equal(
const DetectionPositionPair<T>& a,
const DetectionPositionPair<T>& b,
const std::string& str =
"")
137 return this->check_if_equal_generic(a, b, str);
140 bool check_if_equal(
const LORInAxialAndNoArcCorrSinogramCoordinates<T>& a,
141 const LORInAxialAndNoArcCorrSinogramCoordinates<T>& b,
142 const std::string& str =
"");
147 bool check_if_equal(
const std::complex<T> a,
const std::complex<T> b,
const std::string& str =
"")
149 return check_if_equal(a.real(), b.real(), str) && check_if_equal(a.imag(), b.imag(), str);
157 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
163 if (!check_if_equal(t1[i], t2[i], str))
165 std::cerr <<
"(at VectorWithOffset<" <<
typeid(T).name() <<
"> first mismatch at index " << i <<
")\n";
174 bool check_if_equal(
const std::vector<T>& t1,
const std::vector<T>& t2,
const std::string& str =
"")
176 if (t1.size() != t2.size())
178 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
182 bool all_equal =
true;
183 for (
unsigned int i = 0; i < t1.size(); i++)
185 if (!check_if_equal(t1[i], t2[i], str))
187 std::cerr <<
"(at vector<" <<
typeid(T).name() <<
"> mismatch at index " << i <<
")\n";
202 std::cerr <<
"Error: unequal ranges. " << str << std::endl;
203 return everything_ok =
false;
209 template <
int num_dimensions,
class coordT>
212 const std::string& str =
"")
216 std::cerr <<
"Error : Unequal Coordinate value are " << a <<
" and " << b <<
". " << str << std::endl;
230 bool check_if_zero(
const double a,
const std::string& str =
"");
231 bool check_if_zero(
const short a,
const std::string& str =
"");
232 bool check_if_zero(
const unsigned short a,
const std::string& str =
"");
233 bool check_if_zero(
const int a,
const std::string& str =
"");
234 bool check_if_zero(
const unsigned int a,
const std::string& str =
"");
235 bool check_if_zero(
const long a,
const std::string& str =
"");
236 bool check_if_zero(
const unsigned long a,
const std::string& str =
"");
237#ifdef BOOST_HAS_LONG_LONG
238 bool check_if_zero(
const long long a,
const std::string& str =
"");
239 bool check_if_zero(
const unsigned long long a,
const std::string& str =
"");
247 for (
int i = t.get_min_index(); i <= t.get_max_index(); i++)
251 std::cerr <<
"(at VectorWithOffset<" <<
typeid(T).name() <<
"> first mismatch at index " << i <<
")\n";
259 template <
int num_dimensions,
class coordT>
264 std::cerr <<
"Error : Coordinate value is " << a <<
" expected 0s. " << str << std::endl;
274 template <
class T1,
class T2>
275 inline bool check_if_less(T1 a, T2 b,
const std::string& str =
"");
289 std::cerr <<
"Error : unequal values are \n\t" << a <<
"\n\tand\n\t" << b <<
"\n\t" << str << std::endl;
301 if ((a !=
static_cast<T
>(0)))
303 std::cerr <<
"Error : 0 value is " << a <<
" ." << str << std::endl;
323#if defined(_DEBUG) && defined(__MSL__)
324 DebugNewReportLeaks();
328 std::cerr <<
"\nAll tests ok !\n\n" << std::endl;
330 std::cerr <<
"\nEnd of tests. Please correct errors !\n\n" << std::endl;
362 std::cerr <<
"Error. " << str << std::endl;
369RunTests::check_if_equal(
const std::string& a,
const std::string& b,
const std::string& str)
389RunTests::check_if_equal(
const double a,
const double b,
const std::string& str)
391 const double diff = fabs(b - a);
395 const double largest = (std::max(fabs(b), fabs(a)));
399 std::cerr <<
"Error : unequal values are " << a <<
" and " << b <<
". " << str << std::endl;
408RunTests::check_if_equal(
const short a,
const short b,
const std::string& str)
413RunTests::check_if_equal(
const unsigned short a,
const unsigned short b,
const std::string& str)
418RunTests::check_if_equal(
const int a,
const int b,
const std::string& str)
423RunTests::check_if_equal(
const unsigned int a,
const unsigned int b,
const std::string& str)
428RunTests::check_if_equal(
const long a,
const long b,
const std::string& str)
433RunTests::check_if_equal(
const unsigned long a,
const unsigned long b,
const std::string& str)
437#ifdef BOOST_HAS_LONG_LONG
439RunTests::check_if_equal(
const long long a,
const long long b,
const std::string& str)
444RunTests::check_if_equal(
const unsigned long long a,
const unsigned long long b,
const std::string& str)
454 const std::string& str)
456 bool ok = this->check_if_equal(a.radius(), b.radius(), str +
": radius") && this->check_if_equal(a.z1(), b.z1(), str +
": z1")
457 && this->check_if_equal(a.z2(), b.z2(), str +
": z2") && this->check_if_equal(a.beta(), b.beta(), str +
": beta")
458 && this->check_if_equal(a.phi(), b.phi(), str +
": phi")
459 && this->check_if_equal(a.is_swapped(), b.is_swapped(), str +
": is_swapped");
461 std::cerr <<
"\t(comparing " << a <<
" and " << b <<
")\n";
468 if (*t1.get_proj_data_info_sptr() != *t2.get_proj_data_info_sptr())
470 std::cerr <<
"Error: unequal proj_data_info. " << str << std::endl;
474 for (
auto i1 = t1.begin(), i2 = t2.begin(); i1 != t1.end(); ++i1, ++i2)
476 if (!check_if_equal(*i1, *i2, str))
514#ifdef BOOST_HAS_LONG_LONG
533 std::cerr <<
"Error : 0 value is " << a <<
" ." << str << std::endl;
541template <
class T1,
class T2>
547 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::DetectionPositionPair.
Declaration of class stir::DetectionPosition.
This file defines the stir::IndexRange class.
defines various classes for specifying a line in 3 dimensions
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 for LORs.
Definition LORCoordinates.h:511
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:352
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:153
bool check_if_less(T1 a, T2 b, const std::string &str="")
check if a<b
Definition RunTests.h:543
bool everything_ok
variable storing current status
Definition RunTests.h:281
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:210
bool check(const bool, const std::string &str="")
Tests if true, str can be used to tell what you are testing.
Definition RunTests.h:358
bool is_everything_ok() const
Returns if all checks were fine upto now.
Definition RunTests.h:334
RunTests(const double tolerance=1E-4)
Default constructor.
Definition RunTests.h:316
double tolerance
tolerance for comparisons with real values
Definition RunTests.h:279
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:174
int main_return_value() const
Handy return value for a main() function.
Definition RunTests.h:340
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:147
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:285
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:299
virtual ~RunTests()
Destructor, outputs a diagnostic message.
Definition RunTests.h:321
bool check_if_zero(const double a, const std::string &str="")
Definition RunTests.h:529
bool check_if_zero(const VectorWithOffset< T > &t, const std::string &str="")
use check_if_zero on all elements
Definition RunTests.h:245
void set_tolerance(const double tolerance)
Set value used in floating point comparisons (see check_* functions).
Definition RunTests.h:346
bool check_if_zero(const BasicCoordinate< num_dimensions, coordT > &a, const std::string &str="")
compare norm with tolerance
Definition RunTests.h:260
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.