Changeset 2143


Ignore:
Timestamp:
Jan 15, 2010, 3:12:56 PM (12 years ago)
Author:
Peter
Message:

fixes #449

Location:
trunk/test
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.h

    r2119 r2143  
    123123    template<typename RandomAccessIterator>
    124124    void test_random_access_iterator(RandomAccessIterator);
     125
     126    template<typename Container2D>
     127    void test_concept_container2d(const Container2D&);
     128
     129    template<typename MutableContainer2D>
     130    void test_concept_mutable_container2d(MutableContainer2D&);
    125131
    126132    /**
     
    320326  }
    321327
     328  template<typename Container2D>
     329  void Suite::test_concept_container2d(const Container2D& c)
     330  {
     331    typedef typename Container2D::value_type value_type;
     332    typedef typename Container2D::const_reference const_reference;
     333    typedef typename Container2D::const_iterator const_iterator;
     334    typedef typename Container2D::const_column_iterator const_column_iterator;
     335    typedef typename Container2D::const_row_iterator const_row_iterator;
     336    const_iterator ci = c.begin();
     337    const_column_iterator cci = c.begin_column(0);
     338    const_row_iterator cri = c.begin_row(0);
     339    ci = c.end();
     340    cci = c.end_column(0);
     341    cri = c.end_row(0);
     342    size_t cols = c.columns();
     343    size_t rows = c.rows();
     344    cols = rows; // just to avoid compiler warning
     345    const_reference x = c(0,0);
     346    value_type y;
     347    y = x;
     348  }
     349
     350  template<typename MutableContainer2D>
     351  void Suite::test_concept_mutable_container2d(MutableContainer2D& mc)
     352  {
     353    test_concept_container2d(mc);
     354    typedef typename MutableContainer2D::reference reference;
     355    typedef typename MutableContainer2D::iterator iterator;
     356    typedef typename MutableContainer2D::column_iterator column_iterator;
     357    typedef typename MutableContainer2D::row_iterator row_iterator;
     358    iterator i = mc.begin();
     359    column_iterator ci = mc.begin_column(0);
     360    row_iterator ri = mc.begin_row(0);
     361    *i = *ci;
     362    *ci = *i;
     363    *ri = *i;
     364    i = mc.end();
     365    ci = mc.end_column(0);
     366    ri = mc.end_row(0);
     367    reference x = mc(0,0);
     368    x = *mc.begin();
     369  }
     370
    322371}}}
    323372
  • trunk/test/kernel_lookup_test.cc

    r2119 r2143  
    152152      suite.add((*k6)(s,t)==(*k6)(t,s));
    153153
     154  suite.test_concept_container2d(*k6);
     155
    154156  return suite.return_value();
    155157}
  • trunk/test/matrix_lookup_test.cc

    r2119 r2143  
    169169  delete ValData;
    170170
     171  classifier::MatrixLookup const_m(2,2, 0);
     172  suite.test_concept_container2d(const_m);
     173
    171174  return suite.return_value();
    172175}
  • trunk/test/matrix_lookup_weighted_test.cc

    r1797 r2143  
    8383    suite.err() << "failed.\n";
    8484
     85  classifier::MatrixLookupWeighted const_m(2,2);
     86  suite.test_concept_container2d(const_m);
     87
    8588  return suite.return_value();
    8689}
  • trunk/test/matrix_test.cc

    r2119 r2143  
    237237  m7 = utility::Matrix(0,0);
    238238
     239  const utility::Matrix const_m(2,2,0);
     240  utility::Matrix mutable_m(2,2,0);
     241  // concept compiler tests
     242  suite.test_concept_container2d(const_m);
     243  suite.test_concept_mutable_container2d(mutable_m);
     244
    239245  suite.return_value();
    240246}
  • trunk/test/matrix_weighted_test.cc

    r2119 r2143  
    3333void test_constructor_const(test::Suite& suite);
    3434void test_constructor_matrix(test::Suite& suite);
     35void test_concepts(test::Suite& suite);
    3536void test_swap(test::Suite& suite);
    3637
     
    4344  test_constructor_matrix(suite);
    4445  test_swap(suite);
     46  test_concepts(suite);
    4547
    4648  suite.return_value();
     49}
     50
     51
     52void test_concepts(test::Suite& suite)
     53{
     54  const MatrixWeighted const_m(2,2,0);
     55  MatrixWeighted mutable_m(2,2,0);
     56  // concept compiler tests
     57  suite.test_concept_container2d(const_m);
     58  suite.test_concept_mutable_container2d(mutable_m);
    4759}
    4860
Note: See TracChangeset for help on using the changeset viewer.