27 #ifndef ANTIOCH_REACTION_RATE_VECTOR_TEST_BASE_H
28 #define ANTIOCH_REACTION_RATE_VECTOR_TEST_BASE_H
30 #include "antioch_config.h"
32 #ifdef ANTIOCH_HAVE_CPPUNIT
34 #include <cppunit/extensions/HelperMacros.h>
35 #include <cppunit/TestCase.h>
39 template <
typename ReactionRate,
typename PairScalars>
48 const PairScalars rate = reaction_rate(T);
51 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
53 CPPUNIT_ASSERT_DOUBLES_EQUAL( rate[2*tuple],
57 CPPUNIT_ASSERT_DOUBLES_EQUAL( rate[2*tuple+1],
68 const PairScalars deriv = reaction_rate.derivative(T);
71 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
73 CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv[2*tuple],
77 CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv[2*tuple+1],
90 PairScalars deriv = T;
92 reaction_rate.rate_and_derivative(T,rate,deriv);
97 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
99 CPPUNIT_ASSERT_DOUBLES_EQUAL( rate[2*tuple],
103 CPPUNIT_ASSERT_DOUBLES_EQUAL( rate[2*tuple+1],
107 CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv[2*tuple],
111 CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv[2*tuple+1],
123 PairScalars
setup_T(
const PairScalars& example )
126 PairScalars T = example;
127 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
130 T[2*tuple+1] = 1600.1;
135 virtual PairScalars
exact_rate( PairScalars T ) =0;
136 virtual PairScalars
exact_deriv( PairScalars T ) =0;
142 #endif // ANTIOCH_HAVE_CPPUNIT
144 #endif // ANTIOCH_REACTION_RATE_VECTOR_TEST_BASE_H
void test_rate_and_deriv(const ReactionRate &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)
void test_deriv(const ReactionRate &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)
PairScalars setup_T(const PairScalars &example)
virtual PairScalars exact_rate(PairScalars T)=0
virtual PairScalars exact_deriv(PairScalars T)=0
void test_rate(const ReactionRate &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)