Commit 27e89dea authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Renaming mPreconditioner to tnlPreconditioner.

Renaming mSORSolver to tnlSORSolver.
tnlStack implemented.
tnlTester implemented.
Added tests to Makefile.amS.
tnlObjectTester created.
tnl-unit-tests.cpp created.
tnlStringTester created.
parent 8f194909
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -45,6 +45,22 @@ then
   LDFLAGS="$LDFLAGS -pg"
fi

dnl -----------------------------------------
dnl ----------- check for gcov --------------
dnl -----------------------------------------
AC_ARG_WITH(gcov,
            AS_HELP_STRING([--with-gcov],[compile with gcov support[default=no]]),
            with_gcov=$withval,
            with_gcov=no)
if test x"$with_gcov" = xyes;
then
   CXXFLAGS="-fprofile-arcs -ftest-coverage"
fi

dnl -----------------------------------------
dnl --------- check for dmalloc -------------
dnl -----------------------------------------

AC_ARG_WITH(dmalloc, [  --with-dmalloc=[no/yes/full]	compile with Debug Malloc Library])
if test x"$with_dmalloc" = xfull;
then
@@ -58,6 +74,11 @@ then
  LIBS="$LIBS -ldmalloc"
fi

dnl -----------------------------------------
dnl ---------- check for malloc -------------
dnl -----------------------------------------


AC_ARG_WITH(malloc, [  --with-efence compile with Electric Fence Library])
if test x"$with_efence" = xyes;
then
+7 −0
Original line number Diff line number Diff line
@@ -46,3 +46,10 @@ libtnl_mpi_dbg_0_1_la_LIBADD = debug/libtnldebug-mpi-dbg-0.1.la \
                       diff/libtnldiff-mpi-dbg-0.1.la \
                       matrix/libtnlmatrix-mpi-dbg-0.1.la
endif                       

check_PROGRAMS = tnl-unit-tests
tnl_unit_tests_SOURCES = tnl-unit-tests.cpp
tnl_unit_tests_LDADD = libtnl-0.1.la \
                       core/libcore-tests.la

TESTS = tnl-unit-tests
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -10,8 +10,7 @@ EXTRA_DIST = tnlConfigDescriptionParser.y \
	         tnlConfigDescriptionScanner.l \
	         FlexLexer.h

headers =  \
		  tnlConfigDescription.h \
headers = tnlConfigDescription.h \
		  tnlCurve.h \
		  tnlDataElement.h \
		  tnlField1D.h \
@@ -22,6 +21,7 @@ headers = \
		  tnlLongVector.h \
		  tnlLogger.h \
		  tnlObject.h \
		  tnlStack.h \
		  tnlString.h \
		  tnlConfigDescriptionParser.h \
		  tnlConfigDescriptionParserbase.h \
@@ -30,6 +30,7 @@ headers = \
		  tnlParameterContainer.h \
		  tnlTimerCPU.h \
		  tnlTimerRT.h \
		  tnlTester.h \
		  tnlVector.h \
		  compress-file.h \
		  mfilename.h \
@@ -46,6 +47,7 @@ sources = tnlConfigDescription.cpp \
	  tnlParameterContainer.cpp \
	  tnlTimerCPU.cpp \
	  tnlTimerRT.cpp \
	  tnlTester.cpp \
	  compress-file.cpp \
	  mfilename.cpp \
	  mpi-supp.cpp \
@@ -79,3 +81,9 @@ libtnlcore_mpi_dbg_0_1_la_SOURCES = $(sources) $(headers) debug.h
libtnlcore_mpi_dbg_0_1_la_CXXFLAGS = $(CXXFLAGS) $(MPICXXFLAGS) $(DBGCXXFLAGS)
libtnlcore_mpi_dbg_0_1_la_LDFLAGS = $(LDFLAGS) $(MPICXXFLAGS) $(DBGLDFLAGS)
endif

check_LTLIBRARIES = libcore-tests.la
libcore_tests_la_SOURCES = tnlStringTester.cpp \
                           tnlStringTester.h \
                           tnlObjectTester.cpp \
                           tnlObjectTester.h 
+22 −22
Original line number Diff line number Diff line
@@ -56,13 +56,13 @@ template< class T > class tnlList
   tnlDataElement< T >* last;
   
   //! List size
   long int size;
   int size;

   //! Iterator
   mutable tnlDataElement< T >* iterator;

   //! Iterator index
   mutable long int index;
   mutable int index;

   public:
   //! Basic constructor
@@ -91,10 +91,10 @@ template< class T > class tnlList
   bool IsEmpty() const { return ! size; };
   
   //! Return size of the list
   long int Size() const { return size; };
   int Size() const { return size; };

   //! Indexing operator
   T& operator[] ( long int ind )
   T& operator[] ( int ind )
   {
      assert( ind < size );
      //if( ! size ) return NULL;
@@ -105,7 +105,7 @@ template< class T > class tnlList
      //cout << "List operator[]: size = " << size
      //     << " current index = " << index
      //     << " index = " << ind << endl;
      long int iter_dist = abs( index - ind );
      int iter_dist = abs( index - ind );
      if( ! iterator ||
          iter_dist > ind || 
          iter_dist > size - ind )
@@ -145,7 +145,7 @@ template< class T > class tnlList
   };
   
   //! Indexing operator for constant instances
   const T& operator[] ( long int ind ) const
   const T& operator[] ( int ind ) const
   {
      return const_cast< tnlList< T >* >( this ) -> operator[]( ind );
   }
@@ -191,7 +191,7 @@ template< class T > class tnlList
   };

   //! Insert new data element at given position
   bool Insert( const T& data, long int ind )
   bool Insert( const T& data, int ind )
   {
      assert( ind <= size || ! size );
      if( ind == 0 ) return Prepend( data );
@@ -212,7 +212,7 @@ template< class T > class tnlList
   //! Append copy of another list
   bool AppendList( const tnlList< T >& lst )
   {
      long int i;
      int i;
      for( i = 0; i < lst. Size(); i ++ )
      {
         if( ! Append( lst[ i ] ) ) return false;
@@ -224,14 +224,14 @@ template< class T > class tnlList
   bool PrependList( const tnlList< T >& lst )
   
   {
      long int i;
      int i;
      for( i = lst. Size(); i > 0; i -- )
         if( ! Prepend( lst[ i - 1 ] ) ) return false;
      return true;
   };

   //! Erase data element at given position
   void Erase( long int ind )
   void Erase( int ind )
   {
      operator[]( ind );
      tnlDataElement< T >* tmp_it = iterator;
@@ -252,7 +252,7 @@ template< class T > class tnlList
   };

   //! Erase data element with contained data at given position
   void DeepErase( long int ind )
   void DeepErase( int ind )
   {
      operator[]( ind );
      delete iterator -> Data();
@@ -293,8 +293,8 @@ template< class T > class tnlList
   //! Save the list in binary format
   bool Save( ostream& file ) const
   {
      file. write( ( char* ) &size, sizeof( long int ) );
      long int i;
      file. write( ( char* ) &size, sizeof( int ) );
      int i;
      for( i = 0; i < size; i ++ )
         file. write( ( char* ) & operator[]( i ), sizeof( T ) );
      if( file. bad() ) return false;
@@ -304,8 +304,8 @@ template< class T > class tnlList
   //! Save the list in binary format using method Save of type T
   bool DeepSave( ostream& file ) const
   {
      file. write( ( char* ) &size, sizeof( long int ) );
      long int i;
      file. write( ( char* ) &size, sizeof( int ) );
      int i;
      for( i = 0; i < size; i ++ )
         if( ! operator[]( i ). Save( file ) ) return false;
      if( file. bad() ) return false;
@@ -316,14 +316,14 @@ template< class T > class tnlList
   bool Load( istream& file ) 
   {
      EraseAll();
      long int _size;
      file. read( ( char* ) &_size, sizeof( long int ) );
      int _size;
      file. read( ( char* ) &_size, sizeof( int ) );
      if( _size < 0 )
      {
         cerr << "The curve size is negative." << endl;
         return false;
      }
      long int i;
      int i;
      T t;
      for( i = 0; i < _size; i ++ )
      {
@@ -338,14 +338,14 @@ template< class T > class tnlList
   bool DeepLoad( istream& file ) 
   {
      EraseAll();
      long int _size;
      file. read( ( char* ) &_size, sizeof( long int ) );
      int _size;
      file. read( ( char* ) &_size, sizeof( int ) );
      if( _size < 0 )
      {
         cerr << "The list size is negative." << endl;
         return false;
      }
      long int i;
      int i;
      for( i = 0; i < _size; i ++ )
      {
         T t;
@@ -366,7 +366,7 @@ template< typename T > tnlString GetParameterType( const tnlList< T >& )

template< typename T > ostream& operator << ( ostream& str, const tnlList< T >& list )
{
   long int i, size( list. Size() );
   int i, size( list. Size() );
   for( i = 0; i < size; i ++ )
      str << list[ i ] << endl;
   return str;
+45 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlObjectTester.cpp  -  description
                             -------------------
    begin                : Nov 21, 2009
    copyright            : (C) 2009 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "tnlObjectTester.h"

void tnlObjectTester :: Test( tnlTester& tester )
{
   tester. StartNewUnit( "tnlObject" );
   tnlObjectTester object_tester;

   tester. StartNewTest( "whether tnlObject returns correct type" );
   if( object_tester. GetType() == "tnlObjectTester" )
      tester. FinishTest( tnlTestPASS );
   else tester. FinishTest( tnlTestFAIL );

   tester. StartNewTest( "whether tnlObject correctly set name" );
   const char* name = "tnlObject-unit-test";
   object_tester. SetName( name );
   if( object_tester. GetName() != name )
      tester. FinishTest( tnlTestFAIL );
   else
   {
      object_tester. SetName( "" );
      if( object_tester. GetName() != "" )
         tester. FinishTest( tnlTestFAIL );
      else tester. FinishTest( tnlTestPASS );
   }
   tester. FinishUnit();


}
Loading