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

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

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

revision 537 by jgs, Mon Feb 20 02:00:18 2006 UTC revision 538 by jgs, Mon Feb 20 03:43:25 2006 UTC
# Line 354  void DataTestCase::testSlicing() { Line 354  void DataTestCase::testSlicing() {
354    
355  }  }
356    
357  void DataTestCase::testMore() {  void DataTestCase::testAll() {
358    
359    cout << endl;    cout << endl;
360    
# Line 381  void DataTestCase::testMore() { Line 381  void DataTestCase::testMore() {
381    result=exData*cData;    result=exData*cData;
382    assert(result.isExpanded());    assert(result.isExpanded());
383    
   assert(result.Lsup()==4);  
   assert(result.sup()==4);  
   assert(result.inf()==0);  
   
   result=exData+cData;  
   result=exData-cData;  
   result=exData/cData;  
   
   cout << "\tExercise wherePositive method" << endl;  
   assert(!exData.wherePositive().isEmpty());  
   
   cout << "\tExercise copyWithMask method" << endl;  
   exData.copyWithMask(result, exData.wherePositive());  
   assert(!exData.wherePositive().isEmpty());  
   
384  }  }
385    
386  void DataTestCase::testAll() {  void DataTestCase::testMore() {
387    
388    cout << endl;    cout << endl;
389    
# Line 413  void DataTestCase::testAll() { Line 398  void DataTestCase::testAll() {
398    DataArrayView myView(viewData,viewShape);    DataArrayView myView(viewData,viewShape);
399    
400    bool expanded=true;    bool expanded=true;
   
401    Data exData(myView,FunctionSpace(),expanded);    Data exData(myView,FunctionSpace(),expanded);
402    Data cData(myView);    Data cData(myView);
403    Data result;    Data result;
# Line 426  void DataTestCase::testAll() { Line 410  void DataTestCase::testAll() {
410    result=exData*cData;    result=exData*cData;
411    assert(result.isExpanded());    assert(result.isExpanded());
412    
413      assert(result.Lsup()==4);
414      assert(result.sup()==4);
415      assert(result.inf()==0);
416    
417      result=exData+cData;
418      result=exData-cData;
419      result=exData/cData;
420    
421      cout << "\tExercise wherePositive method" << endl;
422      assert(!exData.wherePositive().isEmpty());
423    
424      cout << "\tExercise copyWithMask method" << endl;
425      exData.copyWithMask(result, exData.wherePositive());
426      assert(!exData.wherePositive().isEmpty());
427    
428  }  }
429    
430  void DataTestCase::testDataConstant() {  void DataTestCase::testDataConstant() {
# Line 467  void DataTestCase::testDataConstant() { Line 466  void DataTestCase::testDataConstant() {
466    
467  }  }
468    
 void DataTestCase::testDataTaggedExceptions() {  
   
   cout << endl;  
   
   cout << "\tTest DataTagged exceptions." << endl;  
   
   Data myData;  
   DataArrayView myView;  
   
   try {  
       myData.getSampleDataByTag(0);;  
       assert(false);  
   }  
   catch (EsysException& e) {  
       //cout << e.what() << endl;  
       assert(true);  
   }  
   
   try {  
       myData.setTaggedValueFromCPP(0,myView);;  
       assert(false);  
   }  
   catch (EsysException& e) {  
       //cout << e.what() << endl;  
       assert(true);  
   }  
   
 }  
   
469  void DataTestCase::testDataTagged() {  void DataTestCase::testDataTagged() {
470    
471    cout << endl;    cout << endl;
472    
473    cout << "\tCreate a DataTagged object with a default value only." << endl;    cout << "\tCreate a DataTagged object with a default value only." << endl;
474    
   // create tagged data with no tag values just a default  
   
475    DataTagged::TagListType keys;    DataTagged::TagListType keys;
476    
477    DataTagged::ValueListType values;    DataTagged::ValueListType values;
# Line 512  void DataTestCase::testDataTagged() { Line 480  void DataTestCase::testDataTagged() {
480    viewShape.push_back(3);    viewShape.push_back(3);
481    
482    DataArrayView::ValueType viewData(3);    DataArrayView::ValueType viewData(3);
483    for (int i=0;i<viewShape[0];++i) {    for (int i=0;i<viewShape[0];i++) {
484      viewData[i]=i;      viewData[i]=i;
485    }    }
486    DataArrayView myView(viewData,viewShape);    DataArrayView defaultValue(viewData,viewShape);
487    
488    bool expanded=false;    bool expanded=false;
489    
490    Data myData(keys,values,myView,FunctionSpace(),expanded);    Data myData(keys,values,defaultValue,FunctionSpace(),expanded);
491    
492    // cout << myData.toString() << endl;    // cout << myData.toString() << endl;
493    
# Line 563  void DataTestCase::testDataTagged() { Line 531  void DataTestCase::testDataTagged() {
531    cout << "\tTest setting of a tag and associated value." << endl;    cout << "\tTest setting of a tag and associated value." << endl;
532    
533    // value for tag "1"    // value for tag "1"
534    DataArray eTwo(myView);    DataArray eTwo(defaultValue);
535    for (int i=0;i<eTwo.getView().getShape()[0];i++) {    for (int i=0;i<eTwo.getView().getShape()[0];i++) {
536      eTwo.getView()(i)=i+2.0;      eTwo.getView()(i)=i+2.0;
537    }    }
# Line 589  void DataTestCase::testDataTagged() { Line 557  void DataTestCase::testDataTagged() {
557    }    }
558    
559  }  }
560    
561    void DataTestCase::testDataTaggedExceptions() {
562    
563      cout << endl;
564    
565      cout << "\tTest DataTagged exceptions." << endl;
566    
567      Data myData;
568      DataArrayView myView;
569    
570      try {
571          myData.getSampleDataByTag(0);;
572          assert(false);
573      }
574      catch (EsysException& e) {
575          //cout << e.what() << endl;
576          assert(true);
577      }
578    
579      try {
580          myData.setTaggedValueFromCPP(0,myView);;
581          assert(false);
582      }
583      catch (EsysException& e) {
584          //cout << e.what() << endl;
585          assert(true);
586      }
587    
588    }
589    
590  void DataTestCase::testConstructors() {  void DataTestCase::testConstructors() {
591    

Legend:
Removed from v.537  
changed lines
  Added in v.538

  ViewVC Help
Powered by ViewVC 1.1.26