/[escript]/trunk/escript/test/DataExpandedTestCase.cpp
ViewVC logotype

Diff of /trunk/escript/test/DataExpandedTestCase.cpp

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

revision 853 by robwdcock, Mon Mar 27 02:43:09 2006 UTC revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC
# Line 128  void DataExpandedTestCase::testAll() { Line 128  void DataExpandedTestCase::testAll() {
128    
129  }  }
130    
 void DataExpandedTestCase::testReshape() {  
   
   cout << endl;  
   
   //  
   // Create a scalar pointData  
   DataArrayView::ShapeType shape;  
   DataArrayView::ValueType data(DataArrayView::noValues(shape),0);  
   DataArrayView pointData(data,shape);  
   
   //  
   // Assign an arbitrary value  
   pointData()=1.0;  
   
   //  
   // Create object to test  
   cout << "\tCreate scalar DataExpanded object." << endl;  
   DataExpanded testData(pointData,FunctionSpace());  
   
   //  
   // Test reshape - legal  
   cout << "\tTest reshape." << endl;  
   shape.push_back(2);  
   shape.push_back(3);  
   shape.push_back(21);  
   testData.reshapeDataPoint(shape);  
   assert(testData.getPointDataView().getRank()==shape.size());  
   
   //  
   // Verify data values  
   cout << "\tVerify data point values." << endl;  
   for (int k=0;k<testData.getPointDataView().getShape()[2];k++) {  
     for (int j=0;j<testData.getPointDataView().getShape()[1];j++) {  
       for (int i=0;i<testData.getPointDataView().getShape()[0];i++) {  
         assert(testData.getPointDataView()(i,j,k)==pointData());  
       }  
     }  
   }  
   
   //  
   // Verify data attributes  
   cout << "\tVerify data point attributes." << endl;  
   DataArrayView dataView=testData.getPointDataView();  
   assert(dataView.getRank()==shape.size());  
   assert(dataView.noValues()==shape[0]*shape[1]*shape[2]);  
   assert(dataView.getShape()[0]==shape[0]);  
   assert(dataView.getShape()[1]==shape[1]);  
   assert(dataView.getShape()[2]==shape[2]);  
   assert(testData.getNumDPPSample()==1);  
   assert(testData.getNumSamples()==1);  
   assert(testData.validSamplePointNo(testData.getNumDPPSample()-1));  
   assert(testData.validSampleNo(testData.getNumSamples()-1));  
   
   //  
   // Test reshape - illegal  
   cout << "\tTest illegal reshape." << endl;  
   try {  
     testData.reshapeDataPoint(shape);  
     assert(false);  
   }  
   catch (EsysException& e) {  
     //cout << e.toString() << endl;  
     assert(true);  
   }  
   
 }  
131    
132  void DataExpandedTestCase::testSlicing() {  void DataExpandedTestCase::testSlicing() {
133    
# Line 635  TestSuite* DataExpandedTestCase::suite ( Line 569  TestSuite* DataExpandedTestCase::suite (
569    // Create the suite of tests to perform.    // Create the suite of tests to perform.
570    TestSuite *testSuite = new TestSuite ("DataExpandedTestCase");    TestSuite *testSuite = new TestSuite ("DataExpandedTestCase");
571    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testAll",&DataExpandedTestCase::testAll));    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testAll",&DataExpandedTestCase::testAll));
   testSuite->addTest (new TestCaller< DataExpandedTestCase>("testReshape",&DataExpandedTestCase::testReshape));  
572    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing",&DataExpandedTestCase::testSlicing));    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing",&DataExpandedTestCase::testSlicing));
573    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing2",&DataExpandedTestCase::testSlicing2));    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing2",&DataExpandedTestCase::testSlicing2));
574    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing3",&DataExpandedTestCase::testSlicing3));    testSuite->addTest (new TestCaller< DataExpandedTestCase>("testSlicing3",&DataExpandedTestCase::testSlicing3));

Legend:
Removed from v.853  
changed lines
  Added in v.854

  ViewVC Help
Powered by ViewVC 1.1.26