Skip to content
Snippets Groups Projects
Commit 70f93bc2 authored by Kurt A. O'Hearn's avatar Kurt A. O'Hearn
Browse files

sPuReMD: update tests.

parent a3b0bde4
No related branches found
No related tags found
No related merge requests found
......@@ -20,9 +20,23 @@ check_PROGRAMS =
TESTS =
if BUILD_TEST
check_PROGRAMS += tests/test_spuremd
check_PROGRAMS += tests/test_lin_alg
check_PROGRAMS += tests/test_vector
TESTS += $(check_PROGRAMS)
tests_test_spuremd_SOURCES = tests/test_spuremd.cpp
tests_test_spuremd_CPPFLAGS = -Isrc $(GTEST_CPPFLAGS)
tests_test_spuremd_CXXFLAGS = $(GTEST_CXXFLAGS)
tests_test_spuremd_LDFLAGS = $(GTEST_LDFLAGS) $(GTEST_LIBS)
tests_test_spuremd_LDADD = lib/libspuremd.la -lgtest
tests_test_lin_alg_SOURCES = tests/test_lin_alg.cpp
tests_test_lin_alg_CPPFLAGS = -Isrc $(GTEST_CPPFLAGS)
tests_test_lin_alg_CXXFLAGS = $(GTEST_CXXFLAGS)
tests_test_lin_alg_LDFLAGS = $(GTEST_LDFLAGS) $(GTEST_LIBS)
tests_test_lin_alg_LDADD = -lgtest
tests_test_vector_SOURCES = tests/test_vector.cpp
tests_test_vector_CPPFLAGS = -Isrc $(GTEST_CPPFLAGS)
tests_test_vector_CXXFLAGS = $(GTEST_CXXFLAGS)
......
......@@ -29,6 +29,10 @@
#include "mytypes.h"
#ifdef __cplusplus
extern "C" {
#endif
void* setup( const char * const, const char * const,
const char * const );
......@@ -40,5 +44,9 @@ int cleanup( const void * const );
reax_atom* get_atoms( const void * const );
#ifdef __cplusplus
}
#endif
#endif
#include <gtest/gtest.h>
#include "mytypes.h"
#include "allocate.c"
#include "lin_alg.c"
#include "list.c"
#include "tool_box.c"
#include "vector.c"
#define VEC_SIZE (100)
namespace
{
class LinAlgTest : public ::testing::Test
{
protected:
real *a, *res;
sparse_matrix *sm;
LinAlgTest( )
{
if ( !Allocate_Matrix( &sm, VEC_SIZE, VEC_SIZE ) ||
(a = (real *) malloc( VEC_SIZE * sizeof(real))) == NULL ||
(res = (real *) malloc( VEC_SIZE * sizeof(real))) == NULL )
{
throw new std::bad_alloc( );
}
}
virtual ~LinAlgTest( )
{
if ( a != NULL )
{
free( a );
}
if ( res != NULL )
{
free( res );
}
if ( sm != NULL )
{
Deallocate_Matrix( sm );
}
}
virtual void SetUp( )
{
for ( int i = 0; i < VEC_SIZE; ++i )
{
a[i] = 1.0;
}
// set up sparse matrix which is an identity matrix in our case
for ( int i = 0; i < sm->n + 1; i++ )
{
sm->start[i] = i;
}
for ( int i = 0; i < sm->start[sm->n]; i++ )
{
sm->j[i] = i;
sm->val[i] = 1.0;
}
}
virtual void TearDown( )
{
}
};
TEST_F(LinAlgTest, Sparse_MatVec)
{
Sparse_MatVec( sm, a, res );
for ( int i = 0; i < VEC_SIZE; ++i )
{
ASSERT_EQ( res[i], a[i] );
}
}
}
int main( int argc, char **argv )
{
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS( );
}
#include <gtest/gtest.h>
#include "spuremd.h"
namespace
{
class SPuReMDTest : public ::testing::Test
{
protected:
void *handle;
SPuReMDTest ( )
{
}
virtual ~SPuReMDTest ( )
{
}
virtual void SetUp( )
{
}
virtual void TearDown( )
{
if ( handle != NULL )
{
cleanup( handle );
}
}
};
TEST_F(SPuReMDTest, water_6540)
{
handle = setup( "../data/benchmarks/water/water_6540.pdb",
"../data/benchmarks/water/ffield.water",
"../environ/param.gpu.water" );
ASSERT_EQ( simulate( handle ), SPUREMD_SUCCESS );
//TODO: check energy after evolving system, e.g., 100 steps
}
TEST_F(SPuReMDTest, silica_6000)
{
handle = setup( "../data/benchmarks/silica/silica_6000.pdb",
"../data/benchmarks/silica/ffield-bio",
"../environ/param.gpu.water" );
ASSERT_EQ( simulate( handle ), SPUREMD_SUCCESS );
//TODO: check energy after evolving system, e.g., 100 steps
}
}
int main( int argc, char **argv )
{
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS( );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment