我的单元测试有以下代码:
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 );
}
这是我的 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));}
};