14 #include <boost/lexical_cast.hpp> 15 #include <boost/scoped_ptr.hpp> 16 #include <boost/test/unit_test.hpp> 19 #include "eckit/config/LocalConfiguration.h" 31 nobias_.reset(
new eckit::LocalConfiguration());
35 boost::scoped_ptr<const eckit::LocalConfiguration>
biasconf_;
36 boost::scoped_ptr<const eckit::LocalConfiguration>
nobias_;
37 boost::scoped_ptr<const eckit::LocalConfiguration>
covconf_;
46 BOOST_CHECK_EQUAL(ob.
value(), biasconf_->getDouble(
"bias"));
51 BOOST_CHECK_EQUAL(ob.
value(), 0.0);
57 BOOST_CHECK_EQUAL(ob2.
value(), biasconf_->getDouble(
"bias"));
65 BOOST_CHECK_EQUAL(ob2.
value(), 0.0);
73 BOOST_CHECK_EQUAL(ob2.
value(), 0.0);
81 BOOST_CHECK_EQUAL(ob2.
value(), 0.0);
93 obsBiasCorrection.
value() = 3.14;
95 ob += obsBiasCorrection;
97 BOOST_CHECK_EQUAL(ob.
value(), biasconf_->getDouble(
"bias") + 3.14);
105 obsBiasCorrection.
value() = 3.14;
107 ob += obsBiasCorrection;
110 BOOST_CHECK_EQUAL(ob.
value(), 0.0);
115 BOOST_CHECK_EQUAL(ob.
value(), biasconf_->getDouble(
"bias"));
131 std::string filename(
"ObsBiasTest.txt");
133 std::ostream os(&fb);
138 std::string inputString;
139 std::string inputBias;
140 double testBias = biasconf_->getDouble(
"bias");
142 int biasStartPos = 10;
143 std::ifstream inputFile(filename.c_str());
144 if (inputFile.is_open()) {
145 getline(inputFile, inputString);
146 getline(inputFile, inputString);
148 inputBias = inputString.substr(biasStartPos);
151 bias = boost::lexical_cast<
double>(inputBias);
153 catch(boost::bad_lexical_cast
const&) {
154 BOOST_ERROR(
"operator<< incorrectly output a non-double");
157 BOOST_CHECK_CLOSE(testBias, bias, 0.0001);
161 BOOST_ERROR(
"operator<< functionality cannot be determined");
167 BOOST_AUTO_TEST_SUITE_END()
boost::scoped_ptr< const eckit::LocalConfiguration > covconf_
boost::scoped_ptr< const eckit::LocalConfiguration > nobias_
Class to handle observation bias parameters.
BOOST_AUTO_TEST_CASE(test_GomL95_constructor)
boost::scoped_ptr< const eckit::LocalConfiguration > biasconf_
static const eckit::Configuration & config()
const double & value() const