/[escript]/branches/schroedinger/escript/test/DataExpandedTestCase.cpp
ViewVC logotype

Diff of /branches/schroedinger/escript/test/DataExpandedTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1863 by jfenwick, Wed Oct 8 00:28:28 2008 UTC revision 1864 by jfenwick, Thu Oct 9 03:09:30 2008 UTC
# Line 16  Line 16 
16  #include "escript/DataExpanded.h"  #include "escript/DataExpanded.h"
17  #include "esysUtils/EsysException.h"  #include "esysUtils/EsysException.h"
18  #include "DataExpandedTestCase.h"  #include "DataExpandedTestCase.h"
19    #include "escript/DataReady.h"
20    
21  #include <iostream>  #include <iostream>
22    
# Line 41  namespace Line 42  namespace
42  {  {
43    
44  ValueType::reference  ValueType::reference
45  getRef(DataAbstract& data,int i, int j)  getRef(DataReady& data,int i, int j)
46  {  {
47     return data.getVector()[getRelIndex(data.getShape(),i,j)];     return data.getVector()[getRelIndex(data.getShape(),i,j)];
48  }  }
49    
50  ValueType::reference  ValueType::reference
51  getRef(DataAbstract& data,int i, int j,int k)  getRef(DataReady& data,int i, int j,int k)
52  {  {
53     return data.getVector()[getRelIndex(data.getShape(),i,j,k)];     return data.getVector()[getRelIndex(data.getShape(),i,j,k)];
54  }  }
# Line 64  getDRef(ValueType& data,const ShapeType& Line 65  getDRef(ValueType& data,const ShapeType&
65     return data[getRelIndex(shape,i,j,k)];     return data[getRelIndex(shape,i,j,k)];
66  }  }
67    
68    DataReady_ptr
69    resolveAndDelete(DataAbstract* p)
70    {
71       DataReady_ptr p2=p->resolve();
72       if (p!=p2.get())
73       {
74        delete p;
75       }
76       return p2;
77    }
78    
79  }  }
80    
81    
# Line 186  void DataExpandedTestCase::testSlicing() Line 198  void DataExpandedTestCase::testSlicing()
198    DataTypes::RegionType region;    DataTypes::RegionType region;
199    region.push_back(DataTypes::RegionType::value_type(0,shape[0]));    region.push_back(DataTypes::RegionType::value_type(0,shape[0]));
200    
201    DataAbstract* testData2=testData.getSlice(region);    DataReady_ptr testData2=resolveAndDelete(testData.getSlice(region));
202    
203    //    //
204    // Verify data values    // Verify data values
# Line 201  void DataExpandedTestCase::testSlicing() Line 213  void DataExpandedTestCase::testSlicing()
213  //   assert(data.getNoValues()==shape[0]*1);  //   assert(data.getNoValues()==shape[0]*1);
214  //   assert(data.getShape()[0]==shape[0]);  //   assert(data.getShape()[0]==shape[0]);
215    
216    delete testData2;  //   delete testData2;
217  }  }
218    
219  void DataExpandedTestCase::testSlicing2() {  void DataExpandedTestCase::testSlicing2() {
# Line 237  void DataExpandedTestCase::testSlicing2( Line 249  void DataExpandedTestCase::testSlicing2(
249    DataTypes::RegionType region;    DataTypes::RegionType region;
250    region.push_back(DataTypes::RegionType::value_type(0,2));    region.push_back(DataTypes::RegionType::value_type(0,2));
251    region.push_back(DataTypes::RegionType::value_type(0,2));    region.push_back(DataTypes::RegionType::value_type(0,2));
252    DataAbstract* testData2=testData.getSlice(region);    
253      DataReady_ptr testData2=resolveAndDelete(testData.getSlice(region));
254    
255    //    //
256    // Verify data values    // Verify data values
# Line 259  void DataExpandedTestCase::testSlicing2( Line 272  void DataExpandedTestCase::testSlicing2(
272    DataTypes::RegionType region2;    DataTypes::RegionType region2;
273    region2.push_back(DataTypes::RegionType::value_type(1,3));    region2.push_back(DataTypes::RegionType::value_type(1,3));
274    region2.push_back(DataTypes::RegionType::value_type(1,3));    region2.push_back(DataTypes::RegionType::value_type(1,3));
275    DataAbstract* testData3=testData.getSlice(region2);    DataReady_ptr testData3=resolveAndDelete(testData.getSlice(region2));
   
276    //    //
277    // Verify data values    // Verify data values
278    cout << "\tVerify data point values." << endl;    cout << "\tVerify data point values." << endl;
# Line 277  void DataExpandedTestCase::testSlicing2( Line 289  void DataExpandedTestCase::testSlicing2(
289    assert(testData3->getShape()[0]==(region2[0].second-region2[0].first));    assert(testData3->getShape()[0]==(region2[0].second-region2[0].first));
290    assert(testData3->getShape()[1]==(region2[1].second-region2[1].first));    assert(testData3->getShape()[1]==(region2[1].second-region2[1].first));
291    
292    delete testData2;  //   delete testData2;
293    delete testData3;  //   delete testData3;
294    
295  }  }
296    
# Line 337  void DataExpandedTestCase::testSlicing3( Line 349  void DataExpandedTestCase::testSlicing3(
349    region.push_back(DataTypes::RegionType::value_type(0,2));    region.push_back(DataTypes::RegionType::value_type(0,2));
350    region.push_back(DataTypes::RegionType::value_type(0,2));    region.push_back(DataTypes::RegionType::value_type(0,2));
351    region.push_back(DataTypes::RegionType::value_type(0,2));    region.push_back(DataTypes::RegionType::value_type(0,2));
352    DataAbstract* testData2=testData.getSlice(region);    DataReady_ptr testData2=resolveAndDelete(testData.getSlice(region));
353    
354    //    //
355    // Verify data values    // Verify data values
# Line 367  void DataExpandedTestCase::testSlicing3( Line 379  void DataExpandedTestCase::testSlicing3(
379    region2.push_back(DataTypes::RegionType::value_type(1,3));    region2.push_back(DataTypes::RegionType::value_type(1,3));
380    region2.push_back(DataTypes::RegionType::value_type(1,3));    region2.push_back(DataTypes::RegionType::value_type(1,3));
381    region2.push_back(DataTypes::RegionType::value_type(1,3));    region2.push_back(DataTypes::RegionType::value_type(1,3));
382    DataAbstract* testData3=testData.getSlice(region2);    DataReady_ptr testData3=resolveAndDelete(testData.getSlice(region2));
383    
384    //    //
385    // Verify data values    // Verify data values
# Line 392  void DataExpandedTestCase::testSlicing3( Line 404  void DataExpandedTestCase::testSlicing3(
404    assert(testData2->getShape()[1]==(region[1].second-region[1].first));    assert(testData2->getShape()[1]==(region[1].second-region[1].first));
405    assert(testData2->getShape()[2]==(region[2].second-region[2].first));    assert(testData2->getShape()[2]==(region[2].second-region[2].first));
406    
407    delete testData2;  //   delete testData2;
408    delete testData3;  //  delete testData3;
409    
410  }  }
411    

Legend:
Removed from v.1863  
changed lines
  Added in v.1864

  ViewVC Help
Powered by ViewVC 1.1.26