C++ main module for stochmagnet Package  1.0
CORE_Test.h
Go to the documentation of this file.
1 #ifndef CORE_Test_H
2 #define CORE_Test_H
3 
4 #include "CORE_Object.h"
5 
6 
7 class CORE_Run;
8 
9 //include map
10 #include <map>
11 
12 //smart pointer heder
13 #include "sp.h"
14 
15 //chrono header
16 #include "CORE_Chrono.h"
17 
18 //Array based on valarray header
19 #include "CORE_StdValArray.h"
20 
21 //Array based on pointers header
22 #include "CORE_StdPtrArray.h"
23 
24 
25 //Field based on valarray hader
26 #include "CORE_StdValField.h"
27 
28 
29 //Field based on ptr header
30 #include "CORE_StdPtrField.h"
31 
32 //strings list
33 #include "CORE_StringsList.h"
34 
44 class CORE_Test : public virtual CORE_Object {
45 
46  // ATTRIBUTES
47 public:
48 
49 
50 private:
51 
52  //flag for king of test to test
53  static const tFlag ALL_TESTS=0;
54  static const tFlag PRIMARY_TESTS=1;
55  static const tFlag ELEMENTARY_TESTS=2;
56  static const tFlag CASE_TESTS=3;
57 
59 
60 public:
61  // METHODS
62 
63  // CONSTRUCTORS
64 
67  CORE_Test(void);
68 
69 
70 
71  // DESTRUCTORS
72 
73 
76  virtual ~CORE_Test(void);
77 
78 
79 
80 public:
81 
82 
83 
84 public :
85  // CREATE class
91  return p;
92  };
93 
94  //MEMORY
95  //======
103  virtual tMemSize getMemorySize() const override {
104  return sizeof(*this)+getContentsMemorySize();
105  }
106 
107 
108 
113  virtual tBoolean execute(const CORE_Run& runner,
114  const std::map<tString,tString>& options) const;
115 
116 
117 
121  inline void setName(const tString& name) {
122  mName=name;
123  }
127  inline const tString& getName() const {
128  return mName;
129  }
130 
136  virtual tBoolean primaryTests(const CORE_Run& runner,
137  const std::map<tString,tString>& options) const;
138 
144  virtual tBoolean elementaryTests(const CORE_Run& runner,
145  const std::map<tString,tString>& options) const;
146 
152  virtual tBoolean caseTests(const CORE_Run& runner,
153  const std::map<tString,tString>& options) const;
154 
155 
156 protected:
160  virtual void getSearchingPaths(std::vector<tString>& vpaths) const {
161  //package name : core within tests/<packageName>
162  //5 : number of levels
163  //{""} local path from the package
164  getSearchingPaths("core",5,{""},vpaths);
165  }
166 
171 
172 
179  void getSearchingPaths(const tString& packageName,
180  const tUSInt& nLevels,
181  const std::vector<tString>& localPaths,
182  std::vector<tString>& vpaths) const;
183 
188  tString searchPath(const tString& f) const;
189 
190 
206  tBoolean testCase(const CORE_Run& runner,const tString& name) const;
207 
215  virtual tBoolean compareResults(const std::map<tString,tString>& options,const tString& resultFile,const tString& referenceFile,const tReal& eps) const;
216 
217 
218 
224  template<typename T,typename Q>
225  requires core_functions::isRealType<T> || core_functions::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  template<typename T,typename Q>
230  requires core_functions::isIntegerType<T> && core_functions::isIntegerType<Q>
231  inline static tBoolean Equals(const T&a, const Q&b) {
232  return (a==b);
233  }
234 
235 
236 private:
243  tBoolean testTypes(const CORE_Run& runner,
244  const std::map<tString,tString>& options) const;
245 
251  tBoolean testIO(const CORE_Run& runner,
252  const std::map<tString,tString>& options) const;
253 
259  tBoolean testChrono(const CORE_Run& runner,
260  const std::map<tString,tString>& options) const;
261 
262 
263 
264 
269  tBoolean testMemorySize(const CORE_Run& runner,
270  const std::map<tString,tString>& options);
271 
276  tBoolean testStringsList(const CORE_Run& runner,
277  const std::map<tString,tString>& options) const;
282  tBoolean testLoops(const CORE_Run& runner,
283  const std::map<tString,tString>& options) const;
284 
285 protected:
286 
291  tBoolean testArray(const CORE_Run& runner,
292  const std::map<tString,tString>& options) const;
293 
294 
295 
300  template<typename T,class I>
302 
307  tBoolean testField(const CORE_Run& runner,
308  const std::map<tString,tString>& options) const;
309 
310 protected:
311 
312  template<typename Q,class I> requires core_functions::isArithmeticType<Q>
314 
315 
316 
317  template<typename Q,typename K,K D,class S,class I>
319 
320 
321 
322 };
323 
324 #include "CORE_Test.hpp"
325 #endif
this class describes an array of values T of dynamical size with algebrical operators and I is an imp...
Definition: CORE_Array.h:89
this class describes an field. A field is composed by
Definition: CORE_Field.h:40
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
abstract base class for most classes.
Definition: CORE_Object.h:48
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
This class is an outpput results generator for stoch magnet program.
Definition: CORE_Run.h:36
This class is a Test class for Stoch Microm package.
Definition: CORE_Test.h:44
requires core_functions::isArithmeticType< Q > tBoolean testArray(CORE_Array< Q, I > &A) const
virtual tBoolean compareResults(const std::map< tString, tString > &options, const tString &resultFile, const tString &referenceFile, const tReal &eps) const
make the difference between the two files
Definition: CORE_Test.cpp:340
tBoolean uniformRandomTest(CORE_Array< T, I > &A, CORE_Array< T, I > &B) const
randomizer test
Definition: CORE_Test.hpp:270
tBoolean testField(CORE_Field< Q, K, D, S, I > &A) const
tBoolean testCase(const CORE_Run &runner, const tString &name) const
execute the test case
Definition: CORE_Test.cpp:249
tBoolean testLoops(const CORE_Run &runner, const std::map< tString, tString > &options) const
test the string array
Definition: CORE_Test.cpp:792
tBoolean testChrono(const CORE_Run &runner, const std::map< tString, tString > &options) const
test Chrono class
Definition: CORE_Test.cpp:648
void setName(const tString &name)
set the test name
Definition: CORE_Test.h:121
static const tFlag ALL_TESTS
Definition: CORE_Test.h:53
static const tFlag PRIMARY_TESTS
Definition: CORE_Test.h:54
tString getSearchingPathsToString() const
get the test path locations into string
Definition: CORE_Test.cpp:90
requires core_functions::isIntegerType< T > &&static core_functions::isIntegerType< Q > tBoolean Equals(const T &a, const Q &b)
Definition: CORE_Test.h:231
tBoolean testArray(const CORE_Run &runner, const std::map< tString, tString > &options) const
test the numeric array
Definition: CORE_Test.cpp:753
virtual ~CORE_Test(void)
destroy
Definition: CORE_Test.cpp:26
virtual tBoolean elementaryTests(const CORE_Run &runner, const std::map< tString, tString > &options) const
execute the elementary tests
Definition: CORE_Test.cpp:235
static CORE_UniquePointer< CORE_Test > New()
create a test class @retrun a new instance of the class
Definition: CORE_Test.h:89
tBoolean testIO(const CORE_Run &runner, const std::map< tString, tString > &options) const
test IO class
Definition: CORE_Test.cpp:561
static const tFlag ELEMENTARY_TESTS
Definition: CORE_Test.h:55
CORE_Test(void)
create
Definition: CORE_Test.cpp:22
virtual void getSearchingPaths(std::vector< tString > &vpaths) const
get the test path locations
Definition: CORE_Test.h:160
tBoolean testField(const CORE_Run &runner, const std::map< tString, tString > &options) const
test the numeric field
Definition: CORE_Test.cpp:772
tBoolean testMemorySize(const CORE_Run &runner, const std::map< tString, tString > &options)
test memory size
Definition: CORE_Test.cpp:731
tString mName
Definition: CORE_Test.h:58
virtual tBoolean execute(const CORE_Run &runner, const std::map< tString, tString > &options) const
execute the tests
Definition: CORE_Test.cpp:106
static const tFlag CASE_TESTS
Definition: CORE_Test.h:56
const tString & getName() const
get the test name
Definition: CORE_Test.h:127
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: CORE_Test.h:103
virtual tBoolean caseTests(const CORE_Run &runner, const std::map< tString, tString > &options) const
execute the case tests
Definition: CORE_Test.cpp:242
tString searchPath(const tString &f) const
retun the path where the file f is withing the searching paths list
Definition: CORE_Test.cpp:75
requires core_functions::isRealType< T > static core_functions::isRealType< Q > tBoolean Equals(const T &a, const Q &b)
retrun true if the two values are equals
Definition: CORE_Test.h:226
virtual tBoolean primaryTests(const CORE_Run &runner, const std::map< tString, tString > &options) const
execute the primary tests
Definition: CORE_Test.cpp:173
tBoolean testStringsList(const CORE_Run &runner, const std::map< tString, tString > &options) const
test the string array
Definition: CORE_Test.cpp:709
tBoolean testTypes(const CORE_Run &runner, const std::map< tString, tString > &options) const
test type
Definition: CORE_Test.cpp:346
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tFlag
Definition: types.h:91
#define tUSInt
Definition: types.h:38
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137