Ignore:
Timestamp:
Sep 25, 2008, 9:01:48 PM (13 years ago)
Author:
Peter
Message:

fixing DataWeightProxy?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/data_weight_proxy_test.cc

    r1533 r1535  
    2525#include "yat/utility/DataWeightProxy.h"
    2626
     27namespace theplu {
     28namespace yat {
     29namespace test {
     30  class ProxyHolder
     31  {
     32  public:
     33    ProxyHolder(utility::DataWeightProxy& proxy)
     34      : proxy_(proxy) {}
     35
     36    inline utility::DataWeightProxy& operator()(void) { return proxy_; }
     37    inline const utility::DataWeightProxy& operator()(void) const
     38    { return proxy_; }
     39  private:
     40    utility::DataWeightProxy& proxy_;
     41  };
     42}}}
     43
    2744using namespace theplu::yat;
    2845
     
    3350
    3451  using utility::DataWeightProxy;
     52  using utility::DataWeight;
    3553
    3654  double x=1.2;
    37   double y=3.14;
    38   DataWeightProxy proxy(x,y);
     55  double w=3.14;
     56  DataWeight xw(x, w);
     57  DataWeightProxy proxy(x,w);
     58  if (xw != proxy) {
     59    suite.add(false);
     60  }
     61  if (proxy != xw) {
     62    suite.add(false);
     63  }
    3964
    40   suite.return_value();
     65  suite.err() << "testing conversion to DataWeight\n";
     66  test::ProxyHolder holder(proxy);
     67  const test::ProxyHolder const_holder(proxy);
     68 
     69  xw = holder();
     70  xw = const_holder();
     71
     72  if (holder() != holder()) {
     73    suite.add(false);
     74  }
     75  if (holder() != const_holder()) {
     76    suite.add(false);
     77  }
     78
     79  suite.err() << "testing assignment\n";
     80  holder().data() = 1.0;
     81  suite.add(suite.equal(holder().data(), 1.0));
     82  holder().weight() = 1.0;
     83  suite.add(suite.equal(holder().weight(), 1.0));
     84
     85  DataWeight xw2(3.14, 0.5);
     86  holder() = xw2;
     87  suite.add(suite.equal(holder().data(), 3.14));
     88  suite.add(suite.equal(holder().weight(), 0.5));
     89
     90  DataWeight xw3;
     91  xw3 = const_holder();
     92  suite.add(suite.equal(xw3.data(), 3.14));
     93  suite.add(suite.equal(xw3.weight(), 0.5));
     94
     95  return suite.return_value();
    4196}
Note: See TracChangeset for help on using the changeset viewer.