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

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

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

revision 3596 by jfenwick, Thu Jan 28 02:03:15 2010 UTC revision 3597 by caltinay, Thu Sep 15 06:03:17 2011 UTC
# Line 12  Line 12 
12  *******************************************************/  *******************************************************/
13    
14    
15    #include "DataLazyTestCase.h"
16    
17  #include "escript/DataConstant.h"  #include "escript/DataConstant.h"
18  #include "escript/DataLazy.h"  #include "escript/DataLazy.h"
19  #include "escript/FunctionSpace.h"  #include "escript/FunctionSpace.h"
20  #include "esysUtils/EsysException.h"  #include "esysUtils/EsysException.h"
21    
22  #include "DataLazyTestCase.h"  #include <cppunit/TestCaller.h>
   
23  #include <iostream>  #include <iostream>
24  #include <boost/shared_ptr.hpp> // for the cast operator  #include <boost/shared_ptr.hpp> // for the cast operator
25    
26  using namespace CppUnitTest;  using namespace CppUnit;
27  using namespace escript;  using namespace escript;
28  using namespace std;  using namespace std;
29  using namespace esysUtils;  using namespace esysUtils;
30  using namespace escript::DataTypes;  using namespace escript::DataTypes;
31  using namespace boost;  using namespace boost;
32    
 void DataLazyTestCase::setUp() {  
   //  
   // This is called before each test is run  
 }  
   
 void DataLazyTestCase::tearDown() {  
   //  
   // This is called after each test has been run  
 }  
   
   
33  // This test file checks the basic properties of lazy data.  // This test file checks the basic properties of lazy data.
34  // It does not check the correctness of particular operations  // It does not check the correctness of particular operations
35    
# Line 145  getLazyGTP(DataTypes::ShapeType& shape, Line 135  getLazyGTP(DataTypes::ShapeType& shape,
135    
136    
137    
138  #define TESTOP(X,V) { DataAbstract_ptr d1=getLazy(shape); assert(d1->X()==V); assert(d1->isLazy());}  #define TESTOP(X,V) { DataAbstract_ptr d1=getLazy(shape); CPPUNIT_ASSERT(d1->X()==V); CPPUNIT_ASSERT(d1->isLazy());}
139    
140  }  }
141    
# Line 157  void DataLazyTestCase::testLazy1() Line 147  void DataLazyTestCase::testLazy1()
147    
148    DataTypes::ShapeType shape;    DataTypes::ShapeType shape;
149    DataAbstract_ptr d1=getLazy(shape);    DataAbstract_ptr d1=getLazy(shape);
150    assert(d1->isLazy());    CPPUNIT_ASSERT(d1->isLazy());
151    
152    for (int i=0;i<5;++i)    for (int i=0;i<5;++i)
153    {    {
# Line 170  void DataLazyTestCase::testLazy1() Line 160  void DataLazyTestCase::testLazy1()
160    }    }
161  }  }
162    
163  #define TESTOPU(X,V,O) { DataAbstract_ptr d1=getLazyU(shape,O); assert(dynamic_pointer_cast<DataLazy>(d1)->X()==V); assert(d1->isLazy());}  #define TESTOPU(X,V,O) { DataAbstract_ptr d1=getLazyU(shape,O); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->X()==V); CPPUNIT_ASSERT(d1->isLazy());}
164  // This method tests the unary op  constructor  // This method tests the unary op  constructor
165  // We aren't checking the correctness of the results here, just that they have the right properties  // We aren't checking the correctness of the results here, just that they have the right properties
166  void DataLazyTestCase::testLazy2()  void DataLazyTestCase::testLazy2()
# Line 180  void DataLazyTestCase::testLazy2() Line 170  void DataLazyTestCase::testLazy2()
170    
171    DataTypes::ShapeType shape;    DataTypes::ShapeType shape;
172    DataAbstract_ptr d1=getLazyU(shape,LOG);    DataAbstract_ptr d1=getLazyU(shape,LOG);
173    assert(d1->isLazy());    CPPUNIT_ASSERT(d1->isLazy());
174    
175    for (int j=SIN;j<=LEZ;++j)    for (int j=SIN;j<=LEZ;++j)
176    {    {
# Line 200  void DataLazyTestCase::testLazy2() Line 190  void DataLazyTestCase::testLazy2()
190    }    }
191  }  }
192    
193  #define TESTOPUP(X,V,O) { DataAbstract_ptr d1=getLazyUP(shape,O,0); assert(dynamic_pointer_cast<DataLazy>(d1)->X()==V); assert(d1->isLazy());}  #define TESTOPUP(X,V,O) { DataAbstract_ptr d1=getLazyUP(shape,O,0); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->X()==V); CPPUNIT_ASSERT(d1->isLazy());}
194  // This method tests the unary op  constructor  // This method tests the unary op  constructor
195  // We aren't checking the correctness of the results here, just that they have the right properties  // We aren't checking the correctness of the results here, just that they have the right properties
196  void DataLazyTestCase::testLazy2p()  void DataLazyTestCase::testLazy2p()
# Line 211  void DataLazyTestCase::testLazy2p() Line 201  void DataLazyTestCase::testLazy2p()
201    DataTypes::ShapeType shape;    DataTypes::ShapeType shape;
202    DataTypes::ShapeType traceshape;    DataTypes::ShapeType traceshape;
203    DataAbstract_ptr d1=getLazyUP(shape,TRANS,0);    DataAbstract_ptr d1=getLazyUP(shape,TRANS,0);
204    assert(d1->isLazy());    CPPUNIT_ASSERT(d1->isLazy());
205    
206    for (int j=TRANS;j<=TRACE;++j)    for (int j=TRANS;j<=TRACE;++j)
207    {    {
# Line 248  void DataLazyTestCase::testLazy2p() Line 238  void DataLazyTestCase::testLazy2p()
238    }    }
239  }  }
240    
241  #define TESTOPB(X,V,O) { DataAbstract_ptr d1=getLazyB(shape,O); assert(dynamic_pointer_cast<DataLazy>(d1)->X()==V); assert(dynamic_pointer_cast<DataLazy>(d1)->isLazy());}  #define TESTOPB(X,V,O) { DataAbstract_ptr d1=getLazyB(shape,O); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->X()==V); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->isLazy());}
242  // This method tests the binary op  constructor  // This method tests the binary op  constructor
243  // We aren't checking the correctness of the results here, just that they have the right properties  // We aren't checking the correctness of the results here, just that they have the right properties
244  void DataLazyTestCase::testLazy3()  void DataLazyTestCase::testLazy3()
# Line 258  void DataLazyTestCase::testLazy3() Line 248  void DataLazyTestCase::testLazy3()
248    
249    DataTypes::ShapeType shape;    DataTypes::ShapeType shape;
250    DataAbstract_ptr d1=getLazyB(shape,ADD);    DataAbstract_ptr d1=getLazyB(shape,ADD);
251    assert(d1->isLazy());    CPPUNIT_ASSERT(d1->isLazy());
252    
253    for (int j=ADD;j<=POW;++j)    for (int j=ADD;j<=POW;++j)
254    {    {
# Line 281  void DataLazyTestCase::testLazy3() Line 271  void DataLazyTestCase::testLazy3()
271    
272    
273    
274  #define TESTOPGTP(X,V,O) { DataAbstract_ptr d1=getLazyGTP(shape,O,0,0); assert(dynamic_pointer_cast<DataLazy>(d1)->X()==V); assert(dynamic_pointer_cast<DataLazy>(d1)->isLazy());}  #define TESTOPGTP(X,V,O) { DataAbstract_ptr d1=getLazyGTP(shape,O,0,0); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->X()==V); CPPUNIT_ASSERT(dynamic_pointer_cast<DataLazy>(d1)->isLazy());}
275    
276  // This method tests the GeneralTensorproduct  constructor  // This method tests the GeneralTensorproduct  constructor
277  // We aren't checking the correctness of the results here, just that they have the right properties  // We aren't checking the correctness of the results here, just that they have the right properties
# Line 294  void DataLazyTestCase::testLazy4() Line 284  void DataLazyTestCase::testLazy4()
284    DataTypes::ShapeType prodshape;    DataTypes::ShapeType prodshape;
285    
286    DataAbstract_ptr d1=getLazyGTP(shape,PROD,0,0);    DataAbstract_ptr d1=getLazyGTP(shape,PROD,0,0);
287    assert(d1->isLazy());    CPPUNIT_ASSERT(d1->isLazy());
288    
289    for (int j=PROD;j<=PROD;++j)    for (int j=PROD;j<=PROD;++j)
290    {    {
# Line 322  void DataLazyTestCase::testLazy4() Line 312  void DataLazyTestCase::testLazy4()
312    
313    
314    
315  TestSuite* DataLazyTestCase::suite ()  TestSuite* DataLazyTestCase::suite()
316  {  {
   //  
317    // create the suite of tests to perform.    // create the suite of tests to perform.
318    TestSuite *testSuite = new TestSuite ("DataLazyTestCase");    TestSuite *testSuite = new TestSuite("DataLazyTestCase");
319    
320    testSuite->addTest (new TestCaller< DataLazyTestCase>("Identity",&DataLazyTestCase::testLazy1));    testSuite->addTest(new TestCaller<DataLazyTestCase>(
321    testSuite->addTest (new TestCaller< DataLazyTestCase>("Unary",&DataLazyTestCase::testLazy2));                "Identity",&DataLazyTestCase::testLazy1));
322    testSuite->addTest (new TestCaller< DataLazyTestCase>("Unary (params)",&DataLazyTestCase::testLazy2p));    testSuite->addTest(new TestCaller<DataLazyTestCase>(
323    testSuite->addTest (new TestCaller< DataLazyTestCase>("Binary",&DataLazyTestCase::testLazy3));                "Unary",&DataLazyTestCase::testLazy2));
324    testSuite->addTest (new TestCaller< DataLazyTestCase>("GTP",&DataLazyTestCase::testLazy4));    testSuite->addTest(new TestCaller<DataLazyTestCase>(
325                  "Unary (params)",&DataLazyTestCase::testLazy2p));
326      testSuite->addTest(new TestCaller<DataLazyTestCase>(
327                  "Binary",&DataLazyTestCase::testLazy3));
328      testSuite->addTest(new TestCaller<DataLazyTestCase>(
329                  "GTP",&DataLazyTestCase::testLazy4));
330    return testSuite;    return testSuite;
331  }  }
332    

Legend:
Removed from v.3596  
changed lines
  Added in v.3597

  ViewVC Help
Powered by ViewVC 1.1.26