Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
actions::BaseAction< T > Class Template Reference

Base class for testing actions. More...

Inheritance diagram for actions::BaseAction< T >:
actions::Add< T > actions::Assign< T > actions::AssignMove< T > actions::Clear< T > actions::Erase< T > actions::EraseRangeAt< T > actions::FailTest< T > actions::FlipSign< T > actions::Insert< T > actions::Optimize< T > actions::Print< T > actions::PrintNonVoid< T > actions::PrintRange< T > actions::PrintSparseVector< T > actions::PushBack< T > actions::Resize< T > actions::ResizeWith< T > actions::Scale< T > actions::ScaleAll< T > actions::SetElement< T > actions::SetValue< T > actions::UnsetElement< T >

Public Types

using This_t = BaseAction< T >
 
typedef TestManagerClass< T > TestClass_t
 
typedef TestClass_t::Data_t Data_t
 type stored More...
 
typedef TestClass_t::Vector_t Vector_t
 type of STL vector More...
 
typedef TestClass_t::SparseVector_t SparseVector_t
 type of sparse vector More...
 

Public Member Functions

 BaseAction ()
 
 BaseAction (int exp_err)
 
virtual ~BaseAction ()
 
This_tset_expected_errors (int exp_err)
 
void describe (TestClass_t &tc, std::ostream &out) const
 Print a description of this action into the specified steam. More...
 
void describe (TestClass_t &tc) const
 Print a description of this action in the test class stream. More...
 
std::string description (TestClass_t &tc) const
 Returns a string with a description of this action. More...
 
void operator() (Vector_t &v) const
 Action performed on a STL vector. More...
 
void operator() (SparseVector_t &v) const
 Action performed on a sparse vector. More...
 

Public Attributes

int expected_errors {0}
 number of errors expected for this action More...
 

Protected Types

using v_citer_t = typename Vector_t::const_iterator
 

Protected Member Functions

virtual void doDescribe (TestClass_t &, std::ostream &out) const
 
virtual void actionOnVector (Vector_t &) const
 
virtual void actionOnSparseVector (SparseVector_t &) const
 

Static Protected Member Functions

template<typename ITER >
static ITER skipRange (ITER start, ITER const end)
 
template<typename ITER >
static ITER skipVoid (ITER start, ITER const end)
 
template<typename ITER >
static ITER rangeStart (ITER const begin, ITER last)
 
template<typename ITER >
static ITER voidStart (ITER const begin, ITER last)
 
template<typename Vector >
static auto findRangeBorders (Vector &v, std::size_t pos)
 
template<typename ITER >
static ITER findRangeStart (Vector_t const &v, std::size_t i, ITER start)
 Returns iterator to the first element of the i-th range after start. More...
 
template<typename ITER >
static ITER findRangeStart (Vector_t const &v, std::size_t i)
 
template<typename ITER >
static ITER findVoidStart (Vector_t const &v, std::size_t i, ITER start)
 
static bool isVoid (Data_t value)
 

Detailed Description

template<typename T>
class actions::BaseAction< T >

Base class for testing actions.

Parameters
Tthe type stored in the containers

An action class performs a definite action on both a STL vector (Vector_t) and on a sparse_vector (SparseVector_t). The interface includes:

Definition at line 75 of file sparse_vector_test.cc.

Member Typedef Documentation

template<typename T >
typedef TestClass_t::Data_t actions::BaseAction< T >::Data_t

type stored

Definition at line 278 of file sparse_vector_test.cc.

template<typename T >
typedef TestClass_t::SparseVector_t actions::BaseAction< T >::SparseVector_t

type of sparse vector

Definition at line 280 of file sparse_vector_test.cc.

template<typename T >
typedef TestManagerClass<T> actions::BaseAction< T >::TestClass_t

Definition at line 277 of file sparse_vector_test.cc.

template<typename T >
using actions::BaseAction< T >::This_t = BaseAction<T>

Definition at line 276 of file sparse_vector_test.cc.

template<typename T >
using actions::BaseAction< T >::v_citer_t = typename Vector_t::const_iterator
protected

Definition at line 311 of file sparse_vector_test.cc.

template<typename T >
typedef TestClass_t::Vector_t actions::BaseAction< T >::Vector_t

type of STL vector

Definition at line 279 of file sparse_vector_test.cc.

Constructor & Destructor Documentation

template<typename T >
actions::BaseAction< T >::BaseAction ( )
inline

Definition at line 285 of file sparse_vector_test.cc.

285 {}
template<typename T >
actions::BaseAction< T >::BaseAction ( int  exp_err)
inline

Definition at line 286 of file sparse_vector_test.cc.

286 : expected_errors(exp_err) {}
int expected_errors
number of errors expected for this action
template<typename T >
virtual actions::BaseAction< T >::~BaseAction ( )
inlinevirtual

Definition at line 288 of file sparse_vector_test.cc.

288 {}

Member Function Documentation

template<typename T >
virtual void actions::BaseAction< T >::actionOnSparseVector ( SparseVector_t ) const
inlineprotectedvirtual
template<typename T >
virtual void actions::BaseAction< T >::actionOnVector ( Vector_t ) const
inlineprotectedvirtual
template<typename T >
void actions::BaseAction< T >::describe ( TestClass_t tc,
std::ostream &  out 
) const
inline

Print a description of this action into the specified steam.

Definition at line 294 of file sparse_vector_test.cc.

295  { doDescribe(tc, out); }
virtual void doDescribe(TestClass_t &, std::ostream &out) const
template<typename T >
void actions::BaseAction< T >::describe ( TestClass_t tc) const
inline

Print a description of this action in the test class stream.

Definition at line 298 of file sparse_vector_test.cc.

298 { return doDescribe(tc, tc.out); }
virtual void doDescribe(TestClass_t &, std::ostream &out) const
template<typename T >
std::string actions::BaseAction< T >::description ( TestClass_t tc) const
inline

Returns a string with a description of this action.

Definition at line 301 of file sparse_vector_test.cc.

302  { std::ostringstream sstr; describe(tc, sstr); return sstr.str(); }
void describe(TestClass_t &tc, std::ostream &out) const
Print a description of this action into the specified steam.
template<typename T >
virtual void actions::BaseAction< T >::doDescribe ( TestClass_t ,
std::ostream &  out 
) const
inlineprotectedvirtual
template<typename T >
template<typename Vector >
static auto actions::BaseAction< T >::findRangeBorders ( Vector v,
std::size_t  pos 
)
inlinestaticprotected

Definition at line 328 of file sparse_vector_test.cc.

329  {
330  if ((pos>= v.size()) || isVoid(v[pos]))
331  return std::make_pair(v.end(), v.end());
332  auto rbegin = rangeStart(v.begin(), v.begin() + pos);
333  auto rend = skipRange(rbegin, v.end());
334  return std::make_pair(rbegin, rend);
335  }
static ITER skipRange(ITER start, ITER const end)
static bool isVoid(Data_t value)
static ITER rangeStart(ITER const begin, ITER last)
size_t size
Definition: lodepng.cpp:55
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::findRangeStart ( Vector_t const &  v,
std::size_t  i,
ITER  start 
)
staticprotected

Returns iterator to the first element of the i-th range after start.

Definition at line 1070 of file sparse_vector_test.cc.

1071 {
1072  auto const end = v.cend();
1073 
1074  start = skipVoid(start, end);
1075  while (start != end) {
1076  if (i-- == 0) break;
1077  start = skipRange(start, end);
1078  start = skipVoid(start, end);
1079  } // while
1080  return start;
1081 } // actions::BaseAction::findRangeStart()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static ITER skipRange(ITER start, ITER const end)
static ITER skipVoid(ITER start, ITER const end)
template<typename T >
template<typename ITER >
static ITER actions::BaseAction< T >::findRangeStart ( Vector_t const &  v,
std::size_t  i 
)
inlinestaticprotected

Definition at line 343 of file sparse_vector_test.cc.

344  { return findRangeStart(v, i, v.cbegin()); }
static ITER findRangeStart(Vector_t const &v, std::size_t i, ITER start)
Returns iterator to the first element of the i-th range after start.
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::findVoidStart ( Vector_t const &  v,
std::size_t  i,
ITER  start 
)
staticprotected

Returns iterator to the first void element of the i-th void area after start.

Definition at line 1086 of file sparse_vector_test.cc.

1087 {
1088  auto const end = v.cend();
1089 
1090  start = skipRange(start, end);
1091  while (start != end) {
1092  if (i-- == 0) break;
1093  start = skipVoid(start, end);
1094  start = skipRange(start, end);
1095  } // while
1096  return start;
1097 } // actions::BaseAction::findVoidStart()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static ITER skipRange(ITER start, ITER const end)
static ITER skipVoid(ITER start, ITER const end)
template<typename T >
static bool actions::BaseAction< T >::isVoid ( Data_t  value)
inlinestaticprotected

Definition at line 351 of file sparse_vector_test.cc.

351 { return SparseVector_t::is_zero(value); }
static value_type is_zero(value_type v)
Returns whether the value is exactly zero.
template<typename T >
void actions::BaseAction< T >::operator() ( Vector_t v) const
inline

Action performed on a STL vector.

Definition at line 305 of file sparse_vector_test.cc.

305 { actionOnVector(v); }
virtual void actionOnVector(Vector_t &) const
template<typename T >
void actions::BaseAction< T >::operator() ( SparseVector_t v) const
inline

Action performed on a sparse vector.

Definition at line 308 of file sparse_vector_test.cc.

308 { actionOnSparseVector(v); }
virtual void actionOnSparseVector(SparseVector_t &) const
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::rangeStart ( ITER const  begin,
ITER  last 
)
staticprotected

Definition at line 1051 of file sparse_vector_test.cc.

1052 {
1053  if (last == begin) return begin;
1054  while (--last != begin) if (isVoid(*last)) break;
1055  return std::next(last);
1056 } // actions::BaseAction::rangeStart()
static bool isVoid(Data_t value)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
template<typename T >
This_t& actions::BaseAction< T >::set_expected_errors ( int  exp_err)
inline

Definition at line 290 of file sparse_vector_test.cc.

291  { expected_errors = exp_err; return *this; }
int expected_errors
number of errors expected for this action
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::skipRange ( ITER  start,
ITER const  end 
)
staticprotected

Definition at line 1036 of file sparse_vector_test.cc.

1036  {
1037  for (; start != end; ++start) if (isVoid(*start)) break;
1038  return start;
1039 } // actions::BaseAction::skipRange()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static bool isVoid(Data_t value)
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::skipVoid ( ITER  start,
ITER const  end 
)
staticprotected

Definition at line 1043 of file sparse_vector_test.cc.

1043  {
1044  for (; start != end; ++start) if (!isVoid(*start)) break;
1045  return start;
1046 } // actions::BaseAction::skipVoid()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static bool isVoid(Data_t value)
template<typename T >
template<typename ITER >
ITER actions::BaseAction< T >::voidStart ( ITER const  begin,
ITER  last 
)
staticprotected

Definition at line 1060 of file sparse_vector_test.cc.

1060  {
1061  if (last == begin) return begin;
1062  while (--last != begin) if (!isVoid(*last)) break;
1063  return std::next(last);
1064 } // actions::BaseAction::voidStart()
static bool isVoid(Data_t value)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72

Member Data Documentation

template<typename T >
int actions::BaseAction< T >::expected_errors {0}

number of errors expected for this action

Definition at line 283 of file sparse_vector_test.cc.


The documentation for this class was generated from the following file: