/[escript]/trunk/escript/test/DataTagged/DataTaggedTestCase.cpp
ViewVC logotype

Diff of /trunk/escript/test/DataTagged/DataTaggedTestCase.cpp

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

revision 548 by jgs, Tue Feb 21 23:52:41 2006 UTC revision 557 by jgs, Wed Feb 22 05:11:56 2006 UTC
# Line 800  void DataTaggedTestCase::testOperations( Line 800  void DataTaggedTestCase::testOperations(
800    }    }
801    
802    {    {
803    
804        cout << "\tTest binaryOp multiplication of DataTagged object with a scalar." << endl;
805    
806        DataTagged myData;
807    
808        DataArray vOne(1.0);
809        DataArray vTwo(2.0);
810        myData.addTaggedValue(1,vOne.getView());
811        myData.addTaggedValue(2,vTwo.getView());
812    
813        DataArray vThree(3.0);
814        DataArrayView right=vThree.getView();
815    
816        //cout << myData.toString() << endl;
817        //cout << right.toString() << endl;
818    
819        binaryOp(myData,right,multiplies<double>());
820    
821        //cout << myData.toString() << endl;
822    
823        assert(myData.getNumSamples()==1);
824        assert(myData.getNumDPPSample()==1);
825    
826        assert(myData.validSamplePointNo(0));
827        assert(myData.validSampleNo(0));
828        assert(!myData.validSamplePointNo(1));
829        assert(!myData.validSampleNo(1));
830    
831        // data-point 0 has tag number 1 by default
832        assert(myData.getTagNumber(0)==1);
833    
834        assert(myData.isCurrentTag(1));
835        assert(myData.isCurrentTag(2));
836    
837        assert(myData.getTagLookup().size()==2);
838    
839        assert(myData.getLength()==3);
840    
841        assert(myData.getPointOffset(0,0)==1);
842    
843        // check result value for tag "1"
844        DataArrayView myDataView = myData.getDataPointByTag(1);
845        assert(!myDataView.isEmpty());
846        assert(myDataView.getOffset()==1);
847        assert(myDataView.getRank()==0);
848        assert(myDataView.noValues()==1);
849        assert(myDataView.getShape().size()==0);
850        assert(myDataView()==3.0);
851    
852        // check result value for tag "2"
853        myDataView = myData.getDataPointByTag(2);
854        assert(!myDataView.isEmpty());
855        assert(myDataView.getOffset()==2);
856        assert(myDataView.getRank()==0);
857        assert(myDataView.noValues()==1);
858        assert(myDataView.getShape().size()==0);
859        assert(myDataView()==6.0);
860    
861        // check result for default value
862        myDataView = myData.getDefaultValue();
863        assert(!myDataView.isEmpty());
864        assert(myDataView.getOffset()==0);
865        assert(myDataView.getRank()==0);
866        assert(myDataView.noValues()==1);
867        assert(myDataView.getShape().size()==0);
868        assert(myDataView()==0.0);
869    
870        // use a non-existent tag so we get a pointer to
871        // the first element of the data array
872        double* sampleData=myData.getSampleDataByTag(9);
873        assert(sampleData[0]==0);
874        assert(sampleData[1]==3);
875        assert(sampleData[2]==6);
876    
877      }
878    
879      {
880      cout << "\tTest binaryOp multiplication of two DataTagged objects with overlapping tag sets." << endl;      cout << "\tTest binaryOp multiplication of two DataTagged objects with overlapping tag sets." << endl;
881    
882      DataTagged myData;      DataTagged myData;

Legend:
Removed from v.548  
changed lines
  Added in v.557

  ViewVC Help
Powered by ViewVC 1.1.26