/[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 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #include <iostream>  #include <iostream>
16  #if (defined _WIN32) && (defined __INTEL_COMPILER)  #if (defined _WIN32) && (defined __INTEL_COMPILER)
# Line 65  getRef(Data& d, int x, int y) Line 64  getRef(Data& d, int x, int y)
64    
65  }  }
66    
67    // This is to test new copy routines, existing tests should remain where they are
68    void DataTestCase::testCopying()
69    {
70      using namespace escript::DataTypes;
71      cout << endl;
72      {
73        // first we test the deep copy
74        cout << "\tTest deep copy DataConstant" << endl;
75        DataTypes::ShapeType shape;
76        shape.push_back(2);
77        shape.push_back(3);
78        DataTypes::ValueType data(DataTypes::noValues(shape),1);
79        DataConstant* dc=new DataConstant(FunctionSpace(),shape,data);
80        Data d(dc);
81        
82        Data* deep=d.copySelf();    // test self copy
83        for (int i=0;i<DataTypes::noValues(shape);++i)
84        {
85           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
86            assert(false);
87        }
88        d.setToZero();
89        for (int i=0;i<DataTypes::noValues(shape);++i)
90        {
91           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
92            assert(false);
93        }
94        d.copy(*deep);          // test copy from object
95        for (int i=0;i<DataTypes::noValues(shape);++i)
96        {
97           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
98            assert(false);
99        }
100        d.setToZero();
101        for (int i=0;i<DataTypes::noValues(shape);++i)
102        {
103           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
104            assert(false);
105        }
106        delete deep;
107      }
108    
109      {
110        // first we test the deep copy
111        cout << "\tTest deep copy DataExpanded" << endl;
112        DataTypes::ShapeType shape;
113        shape.push_back(2);
114        shape.push_back(3);
115        DataTypes::ValueType data(DataTypes::noValues(shape),1);
116        DataExpanded* dc=new DataExpanded(FunctionSpace(),shape,data);
117        Data d(dc);
118        
119        Data* deep=d.copySelf();    // test self copy
120        for (int i=0;i<DataTypes::noValues(shape);++i)
121        {
122           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
123            assert(false);
124        }
125        d.setToZero();
126        for (int i=0;i<DataTypes::noValues(shape);++i)
127        {
128           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
129            assert(false);
130        }
131        d.copy(*deep);          // test copy from object
132        for (int i=0;i<DataTypes::noValues(shape);++i)
133        {
134           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
135            assert(false);
136        }
137        d.setToZero();
138        for (int i=0;i<DataTypes::noValues(shape);++i)
139        {
140           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
141            assert(false);
142        }
143        delete deep;
144      }
145      {
146        // first we test the deep copy
147        cout << "\tTest deep copy DataTagged" << endl;
148        DataTypes::ShapeType shape;
149        shape.push_back(2);
150        shape.push_back(3);
151        DataTypes::ValueType data(DataTypes::noValues(shape),1);
152        DataTagged* dc=new DataTagged(FunctionSpace(),shape,data);
153        Data d(dc);
154        
155        Data* deep=d.copySelf();    // test self copy
156        for (int i=0;i<DataTypes::noValues(shape);++i)
157        {
158           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
159            assert(false);
160        }
161        d.setToZero();
162        for (int i=0;i<DataTypes::noValues(shape);++i)
163        {
164           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
165            assert(false);
166        }
167        d.copy(*deep);          // test copy from object
168        for (int i=0;i<DataTypes::noValues(shape);++i)
169        {
170           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
171            assert(false);
172        }
173        d.setToZero();
174        for (int i=0;i<DataTypes::noValues(shape);++i)
175        {
176           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
177            assert(false);
178        }
179        delete deep;
180      }
181    
182    }
183    
184  void DataTestCase::testSlicing() {  void DataTestCase::testSlicing() {
185    
186    using namespace escript::DataTypes;    using namespace escript::DataTypes;
# Line 1073  TestSuite* DataTestCase::suite () Line 1189  TestSuite* DataTestCase::suite ()
1189    //    //
1190    // create the suite of tests to perform.    // create the suite of tests to perform.
1191    TestSuite *testSuite = new TestSuite ("DataTestCase");    TestSuite *testSuite = new TestSuite ("DataTestCase");
1192      testSuite->addTest (new TestCaller< DataTestCase>("testCopying",&DataTestCase::testCopying));
1193    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));
1194    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));
1195    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.1811

  ViewVC Help
Powered by ViewVC 1.1.26