Reputation: 927
I have the following code for my unit test:
BOOST_AUTO_TEST_CASE (test_adapter) {
boost::random::mt19937 gen;
boost::normal_distribution<> nd1(10.0,31.0);
unsigned int imax = 1000;
std::vector<double> x, x_p;
for (unsigned int k = 0 ; k < 1000 ; k++) {
std::vector<double>().swap(x);
std::vector<double>().swap(x_p);
for (unsigned int i = 0 ; i < imax ; i++) {
x.push_back(nd1(gen));
x_p.push_back(nd1(gen));
}
}
log_rtns <double >lr;
BOOST_CHECK(lr( x, x_p) == false );
}
and this is my log_rtns:
template<class T>
class log_rtns: public std::binary_function<T,T,bool> {
public:
inline bool operator()(T t, T t_p) {return (std::log(t/t_p));}
};
Upvotes: 0
Views: 259
Reputation: 1747
You are creating a log_rtns
variable (here log_rtns lr;
) without specifying the template parameter T
. So you have to write log_rtns<something> lr;
.
I would guess you want log_rtns<double>
, but the lr
variable is not used.
Also you can't call BOOST_CHECK_CLOSE()
on two arrays. You have to do something like
BOOST_CHECK_EQUAL(x.size(), x_p.size());
for (size_t i = 0; i < x.size(); ++i) {
BOOST_CHECK_CLOSE(x[i], x_p[i], 0.00000000000);
}
Upvotes: 2