Ignore:
Timestamp:
Jun 27, 2010, 5:55:32 AM (12 years ago)
Author:
Peter
Message:

replace class PtrCompare? with two function make_ptr_compare that return compose_f_gx_hy functors. closes #632

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility_test.cc

    r2285 r2286  
    470470void test_ptr_compare(test::Suite& suite)
    471471{
    472   double* a = new double(0);
    473   double* b = new double(1);
    474 
    475   utility::PtrCompare<double> ptr_less;
    476   if (!ptr_less(a, b)) {
    477     suite.out() << "ptr_less(a, b) returned false\n";
    478     suite.add(false);
    479   }
    480   if (ptr_less(b, a)) {
    481     suite.out() << "ptr_less(b, a) returned true\n";
    482     suite.add(false);
    483   }
    484 
    485   utility::PtrCompare<double, std::greater<double> > ptr_greater;
    486   if (ptr_greater(a, b)) {
    487     suite.out() << "ptr_greater(a, b) returned true\n";
    488     suite.add(false);
    489   }
    490   if (!ptr_greater(b, a)) {
    491     suite.out() << "ptr_greater(b, a) returned false\n";
    492     suite.add(false);
    493   }
    494   delete a;
    495   delete b;
    496 
     472  using utility::make_ptr_compare;
    497473  std::vector<double*> vec(10);
    498474  std::greater<double> d_greater;
    499   utility::PtrCompare<double, std::greater<double> > ptr_greater2(d_greater);
    500475  for (size_t i=0; i<vec.size(); ++i)
    501476    vec[i] = new double(i);
    502   std::sort(vec.begin(), vec.end(), ptr_greater2);
     477  std::sort(vec.begin(), vec.end(), make_ptr_compare(*vec.begin(), d_greater));
    503478  for (size_t i=1; i<vec.size(); ++i) {
    504479    suite.add( *vec[i-1] > *vec[i]);
    505480  }
     481  std::sort(vec.begin(), vec.end(), make_ptr_compare(*vec.begin()));
     482  for (size_t i=1; i<vec.size(); ++i) {
     483    suite.add( *vec[i-1] < *vec[i]);
     484  }
    506485  for (size_t i=0; i<vec.size(); ++i)
    507486    delete vec[i];
Note: See TracChangeset for help on using the changeset viewer.