/[escript]/temp_trunk_copy/escript/test/DataTaggedTestCase.cpp
ViewVC logotype

Diff of /temp_trunk_copy/escript/test/DataTaggedTestCase.cpp

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

revision 501 by jgs, Wed Feb 8 03:37:20 2006 UTC revision 502 by jgs, Wed Feb 8 03:57:20 2006 UTC
# Line 1183  void DataTaggedTestCase::testAddTaggedVa Line 1183  void DataTaggedTestCase::testAddTaggedVa
1183    
1184  }  }
1185    
1186    void DataTaggedTestCase::testSetTaggedValue() {
1187    
1188      cout << endl;
1189    
1190      {
1191    
1192        cout << "\tTest setting key in DataTagged with three tags." << endl;
1193    
1194        DataTagged::TagListType keys;
1195        keys.push_back(1);
1196        keys.push_back(2);
1197        keys.push_back(3);
1198    
1199        DataTagged::ValueListType values;
1200    
1201        DataArrayView::ShapeType viewShape;
1202        viewShape.push_back(3);
1203    
1204        // default value
1205        DataArrayView::ValueType viewData(3);
1206        for (int i=0;i<viewShape[0];i++) {
1207          viewData[i]=i;
1208        }
1209        DataArrayView myView(viewData,viewShape);
1210    
1211        // value for tag "1"
1212        DataArray eOne(myView);
1213        for (int i=0;i<eOne.getView().getShape()[0];i++) {
1214          eOne.getView()(i)=i+1.0;
1215        }
1216        values.push_back(eOne.getView());
1217    
1218        // value for tag "2"
1219        DataArray eTwo(myView);
1220        for (int i=0;i<eTwo.getView().getShape()[0];i++) {
1221          eTwo.getView()(i)=i+2.0;
1222        }
1223        values.push_back(eTwo.getView());
1224    
1225        // value for tag "3"
1226        DataArray eThree(myView);
1227        for (int i=0;i<eThree.getView().getShape()[0];i++) {
1228          eThree.getView()(i)=i+3.0;
1229        }
1230        values.push_back(eThree.getView());
1231    
1232        DataTagged myData(keys,values,myView,FunctionSpace());
1233    
1234        // new value for tag "2"
1235        for (int i=0;i<eTwo.getView().getShape()[0];i++) {
1236          eTwo.getView()(i)=i+5.0;
1237        }
1238    
1239        myData.setTaggedValue(2,eTwo.getView());
1240    
1241        assert(myData.isCurrentTag(2));
1242    
1243        assert(myData.getTagLookup().size()==3);
1244    
1245        assert(myData.getLength()==12);
1246    
1247        DataArrayView myDataView = myData.getDataPointByTag(2);
1248        assert(myDataView==eTwo.getView());
1249        assert(!myDataView.isEmpty());
1250        assert(myDataView.getOffset()==6);
1251        assert(myDataView.getRank()==1);
1252        assert(myDataView.noValues()==3);
1253        assert(myDataView.getShape().size()==1);
1254        assert(myDataView(0)==5);
1255        assert(myDataView(1)==6);
1256        assert(myDataView(2)==7);
1257    
1258      }
1259    
1260    }
1261    
1262  void DataTaggedTestCase::testAll() {  void DataTaggedTestCase::testAll() {
1263    
1264    cout << endl;    cout << endl;
# Line 1564  TestSuite* DataTaggedTestCase::suite () Line 1640  TestSuite* DataTaggedTestCase::suite ()
1640    TestSuite *testSuite = new TestSuite ("DataTaggedTestCase");    TestSuite *testSuite = new TestSuite ("DataTaggedTestCase");
1641    testSuite->addTest (new TestCaller< DataTaggedTestCase>("testAll",&DataTaggedTestCase::testAll));    testSuite->addTest (new TestCaller< DataTaggedTestCase>("testAll",&DataTaggedTestCase::testAll));
1642    testSuite->addTest (new TestCaller< DataTaggedTestCase>("testAddTaggedValues",&DataTaggedTestCase::testAddTaggedValues));    testSuite->addTest (new TestCaller< DataTaggedTestCase>("testAddTaggedValues",&DataTaggedTestCase::testAddTaggedValues));
1643      testSuite->addTest (new TestCaller< DataTaggedTestCase>("testSetTaggedValue",&DataTaggedTestCase::testSetTaggedValue));
1644  //  testSuite->addTest (new TestCaller< DataTaggedTestCase>("testOperations",&DataTaggedTestCase::testOperations));  //  testSuite->addTest (new TestCaller< DataTaggedTestCase>("testOperations",&DataTaggedTestCase::testOperations));
1645  //  testSuite->addTest (new TestCaller< DataTaggedTestCase>("testReshape",&DataTaggedTestCase::testReshape));  //  testSuite->addTest (new TestCaller< DataTaggedTestCase>("testReshape",&DataTaggedTestCase::testReshape));
1646    return testSuite;    return testSuite;

Legend:
Removed from v.501  
changed lines
  Added in v.502

  ViewVC Help
Powered by ViewVC 1.1.26