/[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 109 by jgs, Thu Dec 23 07:20:12 2004 UTC revision 110 by jgs, Mon Feb 14 04:14:42 2005 UTC
# Line 247  void DataTestCase::testAll() { Line 247  void DataTestCase::testAll() {
247    Data exData(myView,FunctionSpace(),expanded);    Data exData(myView,FunctionSpace(),expanded);
248    Data cData(myView);    Data cData(myView);
249    Data result;    Data result;
   
250    assert(exData.isExpanded());    assert(exData.isExpanded());
251    assert(cData.isConstant());    assert(cData.isConstant());
252    assert(result.isEmpty());    assert(result.isEmpty());
# Line 440  void DataTestCase::testOperations() { Line 439  void DataTestCase::testOperations() {
439    
440  }  }
441    
442    void DataTestCase::testRefValue() {
443    
444      //
445      // Note - this test can't be run as boost::python::numeric::array
446      // objects can only be created and used form within a pythin thread!
447      //
448    
449      cout << endl;
450    
451      cout << "\tTest Data object RefValue methods." << endl;
452    
453      // Create three Data object - DataExpanded, DataConstant and DataEmpty
454      DataArrayView::ValueType viewData;
455      DataArrayView::ShapeType viewShape;
456      viewShape.push_back(3);
457      for (int i=0;i<viewShape[0];++i) {
458        viewData.push_back(i);
459      }
460      DataArrayView myView(viewData,viewShape);
461    
462      bool expanded=true;
463    
464      Data expandedData(myView,FunctionSpace(),expanded);
465      Data constantData(myView);
466      Data emptyData;
467    
468      assert(expandedData.isExpanded());
469      assert(constantData.isConstant());
470      assert(emptyData.isEmpty());
471    
472      // Check assertions are thrown for RefValue methods on DataEmpty
473    
474      int ref = 0;
475      boost::python::numeric::array num_array(1.0);
476    
477      try {
478          emptyData.getRefValue(ref,num_array);
479          assert(false);
480      }
481      catch (EsysException& e) {
482          assert(true);
483      }
484      try {
485          emptyData.setRefValue(ref,num_array);
486          assert(false);
487      }
488      catch (EsysException& e) {
489          assert(true);
490      }
491    
492      // Check assertions are thrown for RefValue methods on DataConstant
493      try {
494          constantData.getRefValue(ref,num_array);
495          assert(false);
496      }
497      catch (EsysException& e) {
498          assert(true);
499      }
500      try {
501          constantData.setRefValue(ref,num_array);
502          assert(false);
503      }
504      catch (EsysException& e) {
505          assert(true);
506      }
507    
508      // Check calls to RefValue methods on DataExpanded
509      expandedData.getRefValue(ref,num_array);
510      expandedData.setRefValue(ref,num_array);
511    
512    }
513    
514  TestSuite* DataTestCase::suite ()  TestSuite* DataTestCase::suite ()
515  {  {
516    //    //
# Line 454  TestSuite* DataTestCase::suite () Line 525  TestSuite* DataTestCase::suite ()
525    testSuite->addTest (new TestCaller< DataTestCase>("testConstructors",&DataTestCase::testConstructors));    testSuite->addTest (new TestCaller< DataTestCase>("testConstructors",&DataTestCase::testConstructors));
526    testSuite->addTest (new TestCaller< DataTestCase>("testSlicing",&DataTestCase::testSlicing));    testSuite->addTest (new TestCaller< DataTestCase>("testSlicing",&DataTestCase::testSlicing));
527    testSuite->addTest (new TestCaller< DataTestCase>("testOperations",&DataTestCase::testOperations));    testSuite->addTest (new TestCaller< DataTestCase>("testOperations",&DataTestCase::testOperations));
528      //testSuite->addTest (new TestCaller< DataTestCase>("testRefValue",&DataTestCase::testRefValue));
529    
530    return testSuite;    return testSuite;
531  }  }

Legend:
Removed from v.109  
changed lines
  Added in v.110

  ViewVC Help
Powered by ViewVC 1.1.26