Changeset 2147


Ignore:
Timestamp:
Jan 17, 2010, 2:43:38 AM (12 years ago)
Author:
Peter
Message:

fixes #581

added archetype classes for concepts Container2D and Mutable
Container2D in namespace test. Using these to test ColumnNormalizer?
and RowNormalizer?.

Location:
trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.h

    r2143 r2147  
    167167   */
    168168  std::string filename(const std::string& local_path);
     169
     170  /*
     171    class to test (at compile time) that a function (or class) works
     172    with a Container2D. Do not run any test using this class because
     173    the class is not really functional at run time.
     174
     175    \see boost/concept_archetype.hpp
     176   */
     177  template<typename T>
     178  class container2d_archetype
     179  {
     180  public:
     181    typedef T value_type;
     182    typedef const T& const_reference;
     183    typedef const T* const_iterator;
     184    typedef const_iterator const_column_iterator;
     185    typedef const_iterator const_row_iterator;
     186    const_iterator begin(void) const { return &element_; }
     187    const_column_iterator begin_column(size_t) const { return &element_; }
     188    const_iterator begin_row(size_t) const { return &element_; }
     189    const_iterator end(void) const { return NULL; }
     190    const_column_iterator end_column(size_t) const { return NULL; }
     191    const_iterator end_row(size_t) const { return NULL; }
     192    size_t columns(void) const { return 0; }
     193    size_t rows(void) const { return 0; }
     194    const_reference operator()(size_t row, size_t column) const
     195    { return element_; }
     196
     197  protected:
     198    T element_;
     199  };
     200
     201  /*
     202    class to test (at compile time) that a function (or class) works
     203    with a MutableContainer2D. Do not run any test using this class because
     204    the class is not really functional at run time.
     205
     206    \see boost/concept_archetype.hpp
     207   */
     208  template<typename T>
     209  class mutable_container2d_archetype : public container2d_archetype<T>
     210  {
     211  public:
     212    typedef T& reference;
     213    typedef T* iterator;
     214    typedef iterator column_iterator;
     215    typedef iterator row_iterator;
     216    iterator begin(void) { return &this->element_; }
     217    column_iterator begin_column(size_t) { return &this->element_; }
     218    iterator begin_row(size_t) { return &this->element_; }
     219    iterator end(void) { return NULL; }
     220    column_iterator end_column(size_t) { return NULL; }
     221    iterator end_row(size_t) { return NULL; }
     222    reference operator()(size_t row, size_t column) const
     223    { return this->element_; }
     224  };
     225
     226  // template implementations
    169227
    170228  template<typename Iterator1, typename Iterator2>
  • trunk/test/normalization_test.cc

    r2146 r2147  
    129129  suite.err() << "Testing m(1,1)\n";
    130130  suite.add(suite.equal(m(1,1), -3));
     131
     132  if (false) { // do not run compile tests
     133    test::container2d_archetype<double> container2d;
     134    test::mutable_container2d_archetype<double> mutable_container2d;
     135    qn(container2d, mutable_container2d);
     136  }
    131137}
    132138
     
    286292  m2.transpose();
    287293  suite.equal_range(m.begin(), m.end(), m2.begin());
     294  if (false) { // do not run compile tests
     295    test::container2d_archetype<double> container2d;
     296    test::mutable_container2d_archetype<double> mutable_container2d;
     297    rn(container2d, mutable_container2d);
     298  }
    288299}
    289300
Note: See TracChangeset for help on using the changeset viewer.