/[escript]/trunk/escript/test/Data/DataTestCase.cpp
ViewVC logotype

Diff of /trunk/escript/test/Data/DataTestCase.cpp

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

revision 97 by jgs, Tue Dec 14 05:39:33 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 382  void DataTestCase::testOperations() { Line 381  void DataTestCase::testOperations() {
381    viewShape.push_back(2);    viewShape.push_back(2);
382    viewShape.push_back(3);    viewShape.push_back(3);
383    
384    Data base(2.0,viewShape,FunctionSpace(),false);    Data base(2.0,viewShape,FunctionSpace(),true);
385    Data power(3.0,viewShape,FunctionSpace(),false);    Data power(3.0,viewShape,FunctionSpace(),true);
386    
387    cout << "\tPerform basic exercises of unary operations" << endl;    cout << "\tPerform basic exercises of unary operations" << endl;
388    
# Line 408  void DataTestCase::testOperations() { Line 407  void DataTestCase::testOperations() {
407    result.copy(base.abs());    result.copy(base.abs());
408    assert(true);    assert(true);
409    
410    result.copy(base.maxval());    result.copy(base.sign());
411    assert(true);    assert(true);
412    
413    result.copy(base.minval());    result.copy(base.exp());
414    assert(true);    assert(true);
415    
416    result.copy(base.length());    result.copy(base.sqrt());
417    assert(true);    assert(true);
418    
419    result.copy(base.sign());    result.copy(base.neg());
420    assert(true);    assert(true);
421    
422    result.copy(base.transpose(0));    result.copy(base.pos());
423    assert(true);    assert(true);
424    
425    result.copy(base.trace());    result.copy(base.minval());
426    assert(true);    assert(true);
427    
428    result.copy(base.exp());    result.copy(base.maxval());
429    assert(true);    assert(true);
430    
431    result.copy(base.sqrt());    result.copy(base.length());
432    assert(true);    assert(true);
433    
434    result.copy(base.neg());    result.copy(base.trace());
435    assert(true);    assert(true);
436    
437    result.copy(base.pos());    //result.copy(base.transpose(0));
438    assert(true);    //assert(true);
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 ()
# Line 453  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.97  
changed lines
  Added in v.110

  ViewVC Help
Powered by ViewVC 1.1.26