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

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

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

revision 539 by jgs, Mon Feb 20 04:12:51 2006 UTC revision 549 by jgs, Wed Feb 22 00:45:48 2006 UTC
# Line 219  void DataTestCase::testSlicing() { Line 219  void DataTestCase::testSlicing() {
219      cout << "\tTest set-slicing DataTagged" << endl;      cout << "\tTest set-slicing DataTagged" << endl;
220    
221      //      //
222      // create a DataTagged with a scalar default value only      // create a source DataTagged with a scalar default value only
223    
224      DataArrayView::ShapeType viewShape;      DataArrayView::ShapeType viewShape;
225      Data source(10.0,viewShape,FunctionSpace(),false);      Data source(10.0,viewShape,FunctionSpace(),false);
226      source.tag();      source.tag();
227    
228      //cout << source.toString() << endl;      //cout << "source:\n" << source.toString() << endl;
229    
230      //      //
231      // create a DataTagged with a rank 2 default value only      // create a target DataTagged with a rank 2 default value only
232    
233      viewShape.push_back(2);      viewShape.push_back(2);
234      viewShape.push_back(3);      viewShape.push_back(3);
235      Data target(1.3,viewShape,FunctionSpace(),false);      Data target(1.3,viewShape,FunctionSpace(),false);
236      target.tag();      target.tag();
237    
238      //cout << target.toString() << endl;      //cout << "target:\n" << target.toString() << endl;
239    
240      //      //
241      // set a slice in target from source      // set a slice in target from source
# Line 246  void DataTestCase::testSlicing() { Line 246  void DataTestCase::testSlicing() {
246    
247      target.setSlice(source,region);      target.setSlice(source,region);
248    
249      //cout << target.toString() << endl;      //cout << "target:\n" << target.toString() << endl;
250    
251      assert(target.isTagged());      assert(target.isTagged());
252      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
# Line 258  void DataTestCase::testSlicing() { Line 258  void DataTestCase::testSlicing() {
258      assert(target.getDataPoint(0,0)(1,2)==1.3);      assert(target.getDataPoint(0,0)(1,2)==1.3);
259    
260      //      //
261      // add a value for tag "1"      // add a value for tag "1" to target
262    
263      DataArrayView::ValueType viewData(6);      DataArrayView::ValueType viewData(6);
264      for (int i=0;i<viewData.size();i++) {      for (int i=0;i<viewData.size();i++) {
# Line 268  void DataTestCase::testSlicing() { Line 268  void DataTestCase::testSlicing() {
268    
269      target.setTaggedValueFromCPP(1, dataView);      target.setTaggedValueFromCPP(1, dataView);
270    
271        //cout << "target:\n" << target.toString() << endl;
272    
273      //      //
274      // set a slice in target from source      // set a slice in target from source
275    
# Line 277  void DataTestCase::testSlicing() { Line 279  void DataTestCase::testSlicing() {
279    
280      target.setSlice(source,region);      target.setSlice(source,region);
281    
282      //cout << target.toString() << endl;      //cout << "target:\n" << target.toString() << endl;
283    
284      assert(target.isTagged());      assert(target.isTagged());
285      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
# Line 288  void DataTestCase::testSlicing() { Line 290  void DataTestCase::testSlicing() {
290      assert(target.getDataPoint(0,0)(1,1)==3);      assert(target.getDataPoint(0,0)(1,1)==3);
291      assert(target.getDataPoint(0,0)(1,2)==5);      assert(target.getDataPoint(0,0)(1,2)==5);
292    
293        //
294        // add a value for tag "2" to source
295    
296        DataArrayView::ShapeType viewShape2;
297        DataArrayView::ValueType viewData2(1);
298        viewData2[0]=6;
299        DataArrayView dataView2(viewData2,viewShape2);
300    
301        source.setTaggedValueFromCPP(2, dataView2);
302    
303        //cout << "source:\n" << source.toString() << endl;
304    
305        //
306        // set a slice in target from source
307    
308        region.clear();
309        region.push_back(DataArrayView::RegionType::value_type(0,0));
310        region.push_back(DataArrayView::RegionType::value_type(1,1));
311    
312        target.setSlice(source,region);
313    
314        //cout << "target:\n" << target.toString() << endl;
315    
316        assert(target.isTagged());
317        assert(target.getDataPointRank()==2);
318    
319        // use a non-existant tag so we get a pointer to the default value
320        // ie: the first element in the data array
321        DataAbstract::ValueType::value_type* targetData=target.getSampleDataByTag(9);
322        for (int i=0; i<target.getLength(); i++) {
323          assert(targetData[i]>=0);
324        }
325        assert(targetData[0]==1.3);
326        assert(targetData[1]==1.3);
327        assert(targetData[2]==10);
328        assert(targetData[3]==10);
329        assert(targetData[4]==1.3);
330        assert(targetData[5]==1.3);
331        assert(targetData[6]==0);
332        assert(targetData[7]==1);
333        assert(targetData[8]==10);
334        assert(targetData[9]==3);
335        assert(targetData[10]==4);
336        assert(targetData[11]==5);
337        assert(targetData[12]==1.3);
338        assert(targetData[13]==1.3);
339        assert(targetData[14]==6);
340        assert(targetData[15]==10);
341        assert(targetData[16]==1.3);
342        assert(targetData[17]==1.3);
343    
344    }    }
345    
346    {    {

Legend:
Removed from v.539  
changed lines
  Added in v.549

  ViewVC Help
Powered by ViewVC 1.1.26