14 #include <boost/lexical_cast.hpp> 15 #include <boost/scoped_ptr.hpp> 16 #include <boost/shared_ptr.hpp> 17 #include <boost/test/unit_test.hpp> 20 #include "eckit/config/LocalConfiguration.h" 36 nobias_.reset(
new eckit::LocalConfiguration());
45 boost::scoped_ptr<lorenz95::Resolution>
resol_;
46 boost::scoped_ptr<const eckit::LocalConfiguration>
biasconf_;
47 boost::scoped_ptr<const eckit::LocalConfiguration>
nobias_;
48 boost::scoped_ptr<lorenz95::ModelBiasCorrection>
dbias_;
59 BOOST_CHECK_EQUAL(mbias.
bias(), bias1_);
67 BOOST_CHECK_EQUAL(mbias.
bias(), 0.0);
73 BOOST_CHECK_EQUAL(mbias2.
bias(), bias1_);
82 BOOST_CHECK_EQUAL(mbias2.
bias(), 0.0);
88 BOOST_CHECK_EQUAL(mbias2.
bias(), bias1_);
96 BOOST_CHECK_EQUAL(mbias2.
bias(), 0.0);
105 BOOST_CHECK_EQUAL(mbias2.
bias(), 0.0);
111 BOOST_CHECK_EQUAL(mbias2.
bias(), 0.0);
120 BOOST_CHECK_EQUAL(mbias.
classname(),
"lorenz95::ModelBias");
128 BOOST_CHECK_EQUAL(mbias.
bias(), bias1_ + bias2_);
138 BOOST_CHECK_EQUAL(mbias.
bias(), 0.0);
143 BOOST_CHECK_EQUAL(mbias.
bias(), bias1_);
159 std::string filename(
"ModelBiasTest.txt");
161 std::ostream os(&fb);
166 std::string inputString;
167 std::string inputBias;
168 double testBias = bias1_;
170 int biasStartPos = 12;
171 std::ifstream inputFile(filename.c_str());
172 if (inputFile.is_open()) {
173 getline(inputFile, inputString);
174 getline(inputFile, inputString);
176 inputBias = inputString.substr(biasStartPos);
179 bias = boost::lexical_cast<
double>(inputBias);
181 catch(boost::bad_lexical_cast
const&) {
182 BOOST_ERROR(
"operator<< incorrectly output a non-double");
185 BOOST_CHECK_CLOSE(testBias, bias, 0.0001);
189 BOOST_ERROR(
"operator<< functionality cannot be determined");
195 BOOST_AUTO_TEST_SUITE_END()
boost::scoped_ptr< lorenz95::ModelBiasCorrection > dbias_
boost::scoped_ptr< const eckit::LocalConfiguration > biasconf_
boost::scoped_ptr< lorenz95::Resolution > resol_
static const std::string classname()
boost::scoped_ptr< const eckit::LocalConfiguration > nobias_
const eckit::Configuration & config() const
const double & bias() const
Model error for Lorenz 95 model.
BOOST_AUTO_TEST_CASE(test_GomL95_constructor)
static const eckit::Configuration & config()