1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/CONCEPT/classTest.h>
///////////////////////////
#include <BALL/MATHS/numericalIntegrator.h>
///////////////////////////
START_TEST(NumericalIntegrator)
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
using namespace BALL;
NumericalIntegrator<MutableConstant<>, float>* ni_ptr = 0;
CHECK(NumericalIntegrator() throw())
ni_ptr = new NumericalIntegrator<MutableConstant<>, float>;
TEST_NOT_EQUAL(ni_ptr, 0)
RESULT
CHECK(~NumericalIntegrator() throw())
delete ni_ptr;
RESULT
CHECK(BALL_CREATE(NumericalIntegrator))
// ???
RESULT
CHECK(NumericalIntegrator(const NumericalIntegrator& nint) throw())
float test_constant = 784.83630;
NumericalIntegrator<MutableConstant<>, float> ni1;
ni1.getFunction().setConstant(test_constant);
NumericalIntegrator<MutableConstant<>, float> ni2;
bool test = (ni1 == ni2);
TEST_NOT_EQUAL(test, true)
NumericalIntegrator<MutableConstant<>, float> ni3(ni1);
test = (ni1 == ni3);
TEST_EQUAL(test, true)
RESULT
CHECK(NumericalIntegrator& operator = (const NumericalIntegrator& nint) throw())
NumericalIntegrator<MutableConstant<>, float> ni1;
float test_constant = 784.83630;
ni1.getFunction().setConstant(test_constant);
NumericalIntegrator<MutableConstant<>, float> ni2;
bool test = (ni1 == ni2);
TEST_NOT_EQUAL(test, true)
ni2 = ni1;
test = (ni1 == ni2);
TEST_EQUAL(test, true)
RESULT
CHECK(bool operator == (const NumericalIntegrator& nint) const throw())
NumericalIntegrator<MutableConstant<>, float> ni1;
float test_constant = 9264.97840;
ni1.getFunction().setConstant(test_constant);
NumericalIntegrator<MutableConstant<>, float> ni2;
bool test = (ni1 == ni2);
TEST_NOT_EQUAL(test, true)
ni2.getFunction().setConstant(test_constant);
test = (ni1 == ni2);
TEST_EQUAL(test, true)
RESULT
CHECK(void setFunction(const Function& function) throw())
Product<float, float> test_function;
float test_constant1 = 3246.2983742;
float test_constant2 = 8752373.0;
test_function.getFirst() = test_constant1;
test_function.getSecond() = test_constant2;
NumericalIntegrator<Product<float, float>, float> ni1;
ni1.setFunction(test_function);
NumericalIntegrator<Product<float, float>, float> ni2;
bool test = (ni1.getFunction() == ni2.getFunction());
TEST_NOT_EQUAL(test, true)
ni2.getFunction().getFirst() = test_constant1;
ni2.getFunction().getSecond() = test_constant2;
test = (ni1.getFunction() == ni2.getFunction());
TEST_EQUAL(test, true)
RESULT
CHECK(const Function& getFunction() const throw())
Product<float, float> test_function;
float test_constant1 = 3246.2983742;
float test_constant2 = 8752373.0;
test_function.getFirst() = test_constant1;
test_function.getSecond() = test_constant2;
NumericalIntegrator<Product<float, float>, float> ni1;
ni1.setFunction(test_function);
NumericalIntegrator<Product<float, float>, float> ni2;
bool test = (ni1.getFunction() == ni2.getFunction());
TEST_NOT_EQUAL(test, true)
ni2.getFunction().getFirst() = test_constant1;
ni2.getFunction().getSecond() = test_constant2;
test = (ni1.getFunction() == ni2.getFunction());
TEST_EQUAL(test, true)
RESULT
CHECK(DataType getValue(const DataType& x) const throw())
Product<MutableConstant<>, MutableConstant<> > test_function;
float test_constant1 = 8375.38723;
float test_constant2 = 0.7364823;
test_function.getFirst() = test_constant1;
test_function.getSecond() = test_constant2;
NumericalIntegrator<Product<MutableConstant<>, MutableConstant<> >, float> ni1;
ni1.setFunction(test_function);
float bla = 453.39874;
float result = ni1.getValue(bla);
PRECISION(0.01)
TEST_REAL_EQUAL(result, 6168.324451)
RESULT
CHECK(DataType integrate(const DataType& from, const DataType& to) const throw())
MutableConstant<> test_function;
float test_constant = 74.816409;
test_function.setConstant(test_constant);
NumericalIntegrator<MutableConstant<> > ni;
ni.setFunction(test_function);
float result = ni.integrate(0.0, 1.0);
TEST_REAL_EQUAL(result, test_constant)
result = ni.integrate(0.0, 2.0);
TEST_REAL_EQUAL(result, 2.0 * test_constant)
RESULT
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
|