persistent_parameter_generator.h
Go to the documentation of this file.
1 
10 #pragma once
11 #include <gtest/gtest.h>
12 
13 
14 namespace illumina{ namespace interop { namespace unittest {
21  template<typename T>
22  class argument_generator : public ::testing::internal::ParamGeneratorInterface<T>
23  {
24  public:
29  argument_generator(const std::vector<T>& vec) : m_vec(vec){}
34  ::testing::internal::ParamIteratorInterface<T>* Begin() const;
39  ::testing::internal::ParamIteratorInterface<T>* End() const;
40 
41  private:
42  const std::vector<T>& m_vec;
43  };
48  template<typename T>
49  class argument_iterator : public ::testing::internal::ParamIteratorInterface<T>
50  {
51  typedef typename std::vector<T>::const_iterator const_iterator;
52  public:
58  argument_iterator(const argument_generator<T>& base, const_iterator it) : m_base(base), m_begin(it), m_current(it)
59  {
60  }
62  virtual ~argument_iterator() {}
69  virtual const ::testing::internal::ParamGeneratorInterface<T>* BaseGenerator() const
70  {
71  return &m_base;
72  }
80  virtual void Advance()
81  {
82  ++m_current;
83  }
89  virtual ::testing::internal::ParamIteratorInterface<T>* Clone() const
90  {
91  return new argument_iterator(*this);
92  }
100  virtual const T* Current() const
101  {
102  return &(*m_current);
103  }
111  virtual bool Equals(const ::testing::internal::ParamIteratorInterface<T>& other) const
112  {
113  return &m_base == other.BaseGenerator() &&
114  m_current == dynamic_cast<const argument_iterator<T>*>(&other)->m_current;
115  }
116  private:
118  : m_base(other.m_base), m_begin(other.m_begin),
119  m_current(other.m_current) {}
120  private:
121  const argument_generator<T>& m_base;
122  const const_iterator m_begin;
123  const_iterator m_current;
124  };
125 
126 
127  template<typename T>
128  ::testing::internal::ParamIteratorInterface<T>* argument_generator<T>::Begin() const
129  {
130  return new argument_iterator<T>(*this, m_vec.begin());
131  }
132  template<typename T>
133  ::testing::internal::ParamIteratorInterface<T>* argument_generator<T>::End() const
134  {
135  return new argument_iterator<T>(*this, m_vec.end());
136  }
137 
144  template<typename T>
145  ::testing::internal::ParamGenerator<T> PersistentValuesIn(const std::vector<T>& values) {
146  return ::testing::internal::ParamGenerator<T>(new argument_generator<T>(values));
147  }
148 }}}
149 
::testing::internal::ParamIteratorInterface< T > * End() const
Definition: persistent_parameter_generator.h:133
virtual const ::testing::internal::ParamGeneratorInterface< T > * BaseGenerator() const
Definition: persistent_parameter_generator.h:69
Definition: enum_description.h:15
virtual const T * Current() const
Definition: persistent_parameter_generator.h:100
virtual ~argument_iterator()
Definition: persistent_parameter_generator.h:62
virtual bool Equals(const ::testing::internal::ParamIteratorInterface< T > &other) const
Definition: persistent_parameter_generator.h:111
argument_iterator(const argument_generator< T > &base, const_iterator it)
Definition: persistent_parameter_generator.h:58
::testing::internal::ParamGenerator< T > PersistentValuesIn(const std::vector< T > &values)
Definition: persistent_parameter_generator.h:145
::testing::internal::ParamIteratorInterface< T > * Begin() const
Definition: persistent_parameter_generator.h:128
virtual ::testing::internal::ParamIteratorInterface< T > * Clone() const
Definition: persistent_parameter_generator.h:89
Definition: persistent_parameter_generator.h:22
Definition: persistent_parameter_generator.h:49
virtual void Advance()
Definition: persistent_parameter_generator.h:80
Definition: enums.h:301
argument_generator(const std::vector< T > &vec)
Definition: persistent_parameter_generator.h:29