C++ mpi module for stochmagnet_main Package
CORE_Test.h
1 #ifndef CORE_Test_H
2 #define CORE_Test_H
3 
4 #include "CORE_Object.h"
5 
6 
7 class CORE_Run;
8 
9 //options list header
10 #include "CORE_OptionsList.h"
11 
12 
13 //chrono header
14 #include "CORE_Chrono.h"
15 
16 //Array based on valarray header
17 #include "CORE_StdValArray.h"
18 
19 //Array based on pointers header
20 #include "CORE_StdPtrArray.h"
21 
22 
23 //Field based on valarray hader
24 #include "CORE_StdValField.h"
25 
26 
27 //Field based on ptr header
28 #include "CORE_StdPtrField.h"
29 
30 //strings list
31 #include "CORE_StringsList.h"
32 
42 class CORE_Test : public virtual CORE_Object {
43 
44  // ATTRIBUTES
45 public:
46 
47 
48 private:
49 
50  //flag for king of test to test
51  static const tFlag ALL_TESTS=0;
52  static const tFlag PRIMARY_TESTS=1;
53  static const tFlag ELEMENTARY_TESTS=2;
54  static const tFlag CASE_TESTS=3;
55 
56  tString mName;
57 
58 public:
59  // METHODS
60 
61  // CONSTRUCTORS
62 
65  CORE_Test(void);
66 
67 
68 
69  // DESTRUCTORS
70 
71 
74  virtual ~CORE_Test(void);
75 
76 
77 
78 public:
79 
80 
81 
82 public :
83  // CREATE class
87  inline static CORE_UniquePointer<CORE_Test> New() {
88  CORE_UniquePointer<CORE_Test> p(new CORE_Test(),CORE_Test::Delete());
89  return p;
90  };
91 
92  //MEMORY
93  //======
101  virtual tMemSize getMemorySize() const override {
102  return sizeof(*this)+getContentsMemorySize();
103  }
104 
105 
106 
111  virtual tBoolean execute(const CORE_Run& runner,
112  const CORE_OptionsList& options) const;
113 
114 
115 
119  inline void setName(const tString& name) {
120  mName=name;
121  }
125  inline const tString& getName() const {
126  return mName;
127  }
128 
134  virtual tBoolean primaryTests(const CORE_Run& runner,
135  const CORE_OptionsList& options) const;
136 
142  virtual tBoolean elementaryTests(const CORE_Run& runner,
143  const CORE_OptionsList& options) const;
144 
150  virtual tBoolean caseTests(const CORE_Run& runner,
151  const CORE_OptionsList& options) const;
152 
153 
154 protected:
158  virtual void getSearchingPaths(std::vector<tString>& vpaths) const {
159  //package name : core within tests/<packageName>
160  //5 : number of levels
161  //{""} local path from the package
162  getSearchingPaths("core",5,{""},vpaths);
163  }
164 
168  tString getSearchingPathsToString() const;
169 
170 
177  void getSearchingPaths(const tString& packageName,
178  const tUSInt& nLevels,
179  const std::vector<tString>& localPaths,
180  std::vector<tString>& vpaths) const;
181 
186  tString searchPath(const tString& f) const;
187 
188 
204  tBoolean testCase(const CORE_Run& runner,const tString& name) const;
205 
213  virtual tBoolean compareResults(const CORE_OptionsList& options,const tString& resultFile,const tString& referenceFile,const tReal& eps) const;
214 
215 
216 
224  template<typename T,typename Q>
225  requires functions_type::isRealType<T> || functions_type::isRealType<Q>
226  inline static tBoolean Equals(const T&a, const Q&b) {
227  return (fabs(b-a)<std::numeric_limits<tFloat>::epsilon());
228  }
229 
237  template<typename T,typename Q>
238  requires functions_type::isIntegerType<T> && functions_type::isIntegerType<Q>
239  inline static tBoolean Equals(const T&a, const Q&b) {
240  return (a==b);
241  }
242 
243 
244 private:
251  tBoolean testTypes(const CORE_Run& runner,
252  const CORE_OptionsList& options) const;
253 
259  tBoolean testIO(const CORE_Run& runner,
260  const CORE_OptionsList& options) const;
261 
267  tBoolean testChrono(const CORE_Run& runner,
268  const CORE_OptionsList& options) const;
269 
270 
271 
272 
277  tBoolean testMemorySize(const CORE_Run& runner,
278  const CORE_OptionsList& options);
279 
284  tBoolean testStringsList(const CORE_Run& runner,
285  const CORE_OptionsList& options) const;
290  tBoolean testLoops(const CORE_Run& runner,
291  const CORE_OptionsList& options) const;
292 
293 protected:
294 
299  tBoolean testArray(const CORE_Run& runner,
300  const CORE_OptionsList& options) const;
301 
302 
303 
308  template<typename T,class I>
309  tBoolean uniformRandomTest(CORE_Array<T,I>& A,CORE_Array<T,I>& B) const;
310 
315  tBoolean testField(const CORE_Run& runner,
316  const CORE_OptionsList& options) const;
317 
318 protected:
319 
327  template<typename T,class I> requires functions_type::isArithmeticType<T>
328  tBoolean testArray(CORE_Array<T,I>& A) const ;
329 
330 
340  template<typename T,typename K,K D,class S,class I>
341  tBoolean testField(CORE_Field<T,K,D,S,I>& A) const ;
342 
343 
344 
345 };
346 
347 #include "CORE_Test.hpp"
348 #endif
this class describes an array of values T of dynamical size with algebrical operators and I is an imp...
Definition: CORE_Array.h:91
this class describes an field. A field is composed by
Definition: CORE_Field.h:49
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
abstract base class for most classes.
Definition: CORE_Object.h:65
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class is an list of options.
Definition: CORE_OptionsList.h:36
This class is a Run class for core package.
Definition: CORE_Run.h:44
This class is a test class for core package.
Definition: CORE_Test.h:42
tBoolean uniformRandomTest(CORE_Array< T, I > &A, CORE_Array< T, I > &B) const
randomizer test
Definition: CORE_Test.hpp:270
tBoolean testArray(const CORE_Run &runner, const CORE_OptionsList &options) const
test the numeric array
Definition: CORE_Test.cpp:754
tBoolean testCase(const CORE_Run &runner, const tString &name) const
execute the test case
Definition: CORE_Test.cpp:252
requires functions_type::isRealType< T > static functions_type::isRealType< Q > tBoolean Equals(const T &a, const Q &b)
retrun true if the two values are equals
Definition: CORE_Test.h:226
void setName(const tString &name)
set the test name
Definition: CORE_Test.h:119
tString getSearchingPathsToString() const
get the test path locations into string
Definition: CORE_Test.cpp:87
virtual ~CORE_Test(void)
destroy
Definition: CORE_Test.cpp:23
static CORE_UniquePointer< CORE_Test > New()
create a test class
Definition: CORE_Test.h:87
virtual tBoolean execute(const CORE_Run &runner, const CORE_OptionsList &options) const
execute the tests
Definition: CORE_Test.cpp:103
CORE_Test(void)
create
Definition: CORE_Test.cpp:19
virtual void getSearchingPaths(std::vector< tString > &vpaths) const
get the test path locations
Definition: CORE_Test.h:158
virtual tBoolean compareResults(const CORE_OptionsList &options, const tString &resultFile, const tString &referenceFile, const tReal &eps) const
make the difference between the two files
Definition: CORE_Test.cpp:342
tBoolean testField(const CORE_Run &runner, const CORE_OptionsList &options) const
test the numeric field
Definition: CORE_Test.cpp:773
virtual tBoolean elementaryTests(const CORE_Run &runner, const CORE_OptionsList &options) const
execute the elementary tests
Definition: CORE_Test.cpp:238
virtual tBoolean caseTests(const CORE_Run &runner, const CORE_OptionsList &options) const
execute the case tests
Definition: CORE_Test.cpp:245
virtual tBoolean primaryTests(const CORE_Run &runner, const CORE_OptionsList &options) const
execute the primary tests
Definition: CORE_Test.cpp:173
const tString & getName() const
get the test name
Definition: CORE_Test.h:125
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: CORE_Test.h:101
tString searchPath(const tString &f) const
retun the path where the file f is withing the searching paths list
Definition: CORE_Test.cpp:72
requires functions_type::isIntegerType< T > &&static functions_type::isIntegerType< Q > tBoolean Equals(const T &a, const Q &b)
retrun true if the two values are equals
Definition: CORE_Test.h:239