/[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 100 by jgs, Wed Dec 15 03:48:48 2004 UTC revision 110 by jgs, Mon Feb 14 04:14:42 2005 UTC
# Line 220  void DataTestCase::testMore() { Line 220  void DataTestCase::testMore() {
220    
221    cout << "\tExercise wherePositive method" << endl;    cout << "\tExercise wherePositive method" << endl;
222    assert(!exData.wherePositive().isEmpty());    assert(!exData.wherePositive().isEmpty());
223    assert(exData.wherePositive()==exData.wherePositive());    //assert(exData.wherePositive()==exData.wherePositive());
224    
225    cout << "\tExercise copyWithMask method" << endl;    cout << "\tExercise copyWithMask method" << endl;
226    exData.copyWithMask(result, exData.wherePositive());    exData.copyWithMask(result, exData.wherePositive());
# 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 << "\tTest powD,sin,cos,tan,log,ln operations" << endl;    cout << "\tPerform basic exercises of unary operations" << endl;
388    
389    Data result(base.powD(power));    Data result(base.powD(power));
390    assert(result.getDataPoint(0,0)(0,0) == 8);    assert(result.getDataPoint(0,0)(0,0) == 8);
391    
392    result.copy(base.sin());    result.copy(base.sin());
393      assert(true);
394    
395    result.copy(base.cos());    result.copy(base.cos());
396      assert(true);
397    
398    result.copy(base.tan());    result.copy(base.tan());
399      assert(true);
400    
401    result.copy(base.log());    result.copy(base.log());
402      assert(true);
403    
404    result.copy(base.ln());    result.copy(base.ln());
405      assert(true);
406    
407      result.copy(base.abs());
408      assert(true);
409    
410      result.copy(base.sign());
411      assert(true);
412    
413      result.copy(base.exp());
414      assert(true);
415    
416      result.copy(base.sqrt());
417      assert(true);
418    
419      result.copy(base.neg());
420      assert(true);
421    
422      result.copy(base.pos());
423      assert(true);
424    
425      result.copy(base.minval());
426      assert(true);
427    
428      result.copy(base.maxval());
429      assert(true);
430    
431      result.copy(base.length());
432      assert(true);
433    
434      result.copy(base.trace());
435      assert(true);
436    
437      //result.copy(base.transpose(0));
438      //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 411  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.100  
changed lines
  Added in v.110

  ViewVC Help
Powered by ViewVC 1.1.26