/[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 713 by gross, Thu Apr 27 05:03:44 2006 UTC revision 1026 by phornby, Tue Mar 13 08:25:00 2007 UTC
# Line 12  Line 12 
12   *                                                                           *   *                                                                           *
13   *****************************************************************************   *****************************************************************************
14  */  */
15    #include <iostream>
16    #if (defined _WIN32) && (defined __INTEL_COMPILER)
17    #include <mathimf.h>
18    #else
19    #include <math.h>
20    #endif
21    
22  #include "DataTestCase.h"  #include "DataTestCase.h"
23    
# Line 20  Line 26 
26    
27  #include "escript/Data.h"  #include "escript/Data.h"
28    
 #include <iostream>  
 #include <math.h>  
29    
30  using namespace std;  using namespace std;
31  using namespace CppUnitTest;  using namespace CppUnitTest;
# Line 986  void DataTestCase::testOperations() { Line 990  void DataTestCase::testOperations() {
990    assert(std::abs(resultCon.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultCon.getPointDataView()() - 5) <= REL_TOL*5);
991    assert(std::abs(resultTag.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultTag.getPointDataView()() - 5) <= REL_TOL*5);
992    
   cout << "\tTest Data::trace." << endl;  
   resultEx.copy(baseEx.trace());  
   resultCon.copy(baseCon.trace());  
   resultTag.copy(baseTag.trace());  
   assert(std::abs(resultEx.getPointDataView()() - 15) <= REL_TOL*15);  
   assert(std::abs(resultCon.getPointDataView()() - 15) <= REL_TOL*15);  
   assert(std::abs(resultTag.getPointDataView()() - 15) <= REL_TOL*15);  
   
993  }  }
994    
 void DataTestCase::testRefValue() {  
   
   //  
   // Note - this test can't be run as boost::python::numeric::array  
   // objects can only be created and used from within a python thread!  
   //  
   
   cout << endl;  
   
   cout << "\tTest Data object RefValue methods." << endl;  
   
   // Create three Data object - DataExpanded, DataConstant and DataEmpty  
   DataArrayView::ShapeType viewShape;  
   viewShape.push_back(3);  
   DataArrayView::ValueType viewData(3);  
   for (int i=0;i<viewShape[0];++i) {  
     viewData[i]=i;  
   }  
   DataArrayView myView(viewData,viewShape);  
   
   bool expanded=true;  
   
   Data expandedData(myView,FunctionSpace(),expanded);  
   Data constantData(myView);  
   Data emptyData;  
   
   assert(expandedData.isExpanded());  
   assert(constantData.isConstant());  
   assert(emptyData.isEmpty());  
   
   // Check assertions are thrown for RefValue methods on DataEmpty  
   
   int ref = 0;  
   boost::python::numeric::array num_array(1.0);  
   
   try {  
       emptyData.getRefValue(ref,num_array);  
       assert(false);  
   }  
   catch (EsysException& e) {  
       assert(true);  
   }  
   try {  
       emptyData.setRefValue(ref,num_array);  
       assert(false);  
   }  
   catch (EsysException& e) {  
       assert(true);  
   }  
   
   // Check assertions are thrown for RefValue methods on DataConstant  
   try {  
       constantData.getRefValue(ref,num_array);  
       assert(false);  
   }  
   catch (EsysException& e) {  
       assert(true);  
   }  
   try {  
       constantData.setRefValue(ref,num_array);  
       assert(false);  
   }  
   catch (EsysException& e) {  
       assert(true);  
   }  
   
   // Check calls to RefValue methods on DataExpanded  
   expandedData.getRefValue(ref,num_array);  
   expandedData.setRefValue(ref,num_array);  
   
 }  
995    
996  void DataTestCase::testMemAlloc() {  void DataTestCase::testMemAlloc() {
997    

Legend:
Removed from v.713  
changed lines
  Added in v.1026

  ViewVC Help
Powered by ViewVC 1.1.26