/[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 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC revision 1799 by jfenwick, Wed Sep 17 06:33:18 2008 UTC
# Line 65  getRef(Data& d, int x, int y) Line 65  getRef(Data& d, int x, int y)
65    
66  }  }
67    
68    // This is to test new copy routines, existing tests should remain where they are
69    void DataTestCase::testCopying()
70    {
71      using namespace escript::DataTypes;
72      cout << endl;
73      {
74        // first we test the deep copy
75        cout << "\tTest deep copy DataConstant" << endl;
76        DataTypes::ShapeType shape;
77        shape.push_back(2);
78        shape.push_back(3);
79        DataTypes::ValueType data(DataTypes::noValues(shape),1);
80        DataConstant* dc=new DataConstant(FunctionSpace(),shape,data);
81        Data d(dc);
82        
83        Data* deep=d.copySelf();    // test self copy
84        for (int i=0;i<DataTypes::noValues(shape);++i)
85        {
86           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
87            assert(false);
88        }
89        d.setToZero();
90        for (int i=0;i<DataTypes::noValues(shape);++i)
91        {
92           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
93            assert(false);
94        }
95        d.copy(*deep);          // test copy from object
96        for (int i=0;i<DataTypes::noValues(shape);++i)
97        {
98           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
99            assert(false);
100        }
101        d.setToZero();
102        for (int i=0;i<DataTypes::noValues(shape);++i)
103        {
104           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
105            assert(false);
106        }
107        delete deep;
108      }
109    
110      {
111        // first we test the deep copy
112        cout << "\tTest deep copy DataExpanded" << endl;
113        DataTypes::ShapeType shape;
114        shape.push_back(2);
115        shape.push_back(3);
116        DataTypes::ValueType data(DataTypes::noValues(shape),1);
117        DataExpanded* dc=new DataExpanded(FunctionSpace(),shape,data);
118        Data d(dc);
119        
120        Data* deep=d.copySelf();    // test self copy
121        for (int i=0;i<DataTypes::noValues(shape);++i)
122        {
123           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
124            assert(false);
125        }
126        d.setToZero();
127        for (int i=0;i<DataTypes::noValues(shape);++i)
128        {
129           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
130            assert(false);
131        }
132        d.copy(*deep);          // test copy from object
133        for (int i=0;i<DataTypes::noValues(shape);++i)
134        {
135           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
136            assert(false);
137        }
138        d.setToZero();
139        for (int i=0;i<DataTypes::noValues(shape);++i)
140        {
141           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
142            assert(false);
143        }
144        delete deep;
145      }
146      {
147        // first we test the deep copy
148        cout << "\tTest deep copy DataTagged" << endl;
149        DataTypes::ShapeType shape;
150        shape.push_back(2);
151        shape.push_back(3);
152        DataTypes::ValueType data(DataTypes::noValues(shape),1);
153        DataTagged* dc=new DataTagged(FunctionSpace(),shape,data);
154        Data d(dc);
155        
156        Data* deep=d.copySelf();    // test self copy
157        for (int i=0;i<DataTypes::noValues(shape);++i)
158        {
159           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
160            assert(false);
161        }
162        d.setToZero();
163        for (int i=0;i<DataTypes::noValues(shape);++i)
164        {
165           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
166            assert(false);
167        }
168        d.copy(*deep);          // test copy from object
169        for (int i=0;i<DataTypes::noValues(shape);++i)
170        {
171           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
172            assert(false);
173        }
174        d.setToZero();
175        for (int i=0;i<DataTypes::noValues(shape);++i)
176        {
177           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
178            assert(false);
179        }
180        delete deep;
181      }
182    
183    }
184    
185  void DataTestCase::testSlicing() {  void DataTestCase::testSlicing() {
186    
187    using namespace escript::DataTypes;    using namespace escript::DataTypes;
# Line 1073  TestSuite* DataTestCase::suite () Line 1190  TestSuite* DataTestCase::suite ()
1190    //    //
1191    // create the suite of tests to perform.    // create the suite of tests to perform.
1192    TestSuite *testSuite = new TestSuite ("DataTestCase");    TestSuite *testSuite = new TestSuite ("DataTestCase");
1193      testSuite->addTest (new TestCaller< DataTestCase>("testCopying",&DataTestCase::testCopying));
1194    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));
1195    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));
1196    testSuite->addTest (new TestCaller< DataTestCase>("testDataConstant",&DataTestCase::testDataConstant));    testSuite->addTest (new TestCaller< DataTestCase>("testDataConstant",&DataTestCase::testDataConstant));

Legend:
Removed from v.1796  
changed lines
  Added in v.1799

  ViewVC Help
Powered by ViewVC 1.1.26