Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/gslvectorunittest.cpp

    r9b6b2f rb11d3b  
    1313
    1414#include "gslvectorunittest.hpp"
    15 
    16 #ifdef HAVE_TESTRUNNER
    17 #include "UnitTestMain.hpp"
    18 #endif /*HAVE_TESTRUNNER*/
    1915
    2016/********************************************** Test classes **************************************/
     
    117113    CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) );
    118114};
     115
     116
     117/** UnitTest for operators.
     118 */
     119void GSLVectorTest::OperatorIsTest()
     120{
     121  GSLVector zero(3);
     122  GSLVector unit(3);
     123  zero.SetZero();
     124  unit.SetZero();
     125  unit.Set(1,1.);
     126  // summation and scaling
     127  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     128  CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() );
     129  CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() );
     130  CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() );
     131};
     132
     133/** UnitTest for operators.
     134 */
     135void GSLVectorTest::OperatorAlgebraTest()
     136{
     137  GSLVector zero(3);
     138  GSLVector unit(3);
     139  zero.SetZero();
     140  unit.SetZero();
     141  unit.Set(1,1.);
     142  // summation and scaling
     143  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
     144  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
     145  CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() );
     146  CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() );
     147  CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() );
     148  CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() );
     149  CPPUNIT_ASSERT_EQUAL( false, (0.98*unit).IsOne() );
     150  CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() );
     151  CPPUNIT_ASSERT_EQUAL( true, (1.*unit).IsOne() );
     152
     153  CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) );
     154  CPPUNIT_ASSERT_EQUAL( zero, (zero+zero) );
     155  CPPUNIT_ASSERT_EQUAL( unit, (unit+zero) );
     156
     157  unit += zero;
     158  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     159  unit *= 1.;
     160  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     161};
     162
     163/********************************************** Main routine **************************************/
     164
     165int main(int argc, char **argv)
     166{
     167  // Get the top level suite from the registry
     168  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
     169
     170  // Adds the test to the list of test to run
     171  CppUnit::TextUi::TestRunner runner;
     172  runner.addTest( suite );
     173
     174  // Change the default outputter to a compiler error format outputter
     175  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
     176                                                       std::cerr ) );
     177  // Run the tests.
     178  bool wasSucessful = runner.run();
     179
     180  // Return error code 1 if the one of test failed.
     181  return wasSucessful ? 0 : 1;
     182};
Note: See TracChangeset for help on using the changeset viewer.