Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-20 02:47:01

0001 #include <cmath>
0002 #include <cppunit/extensions/HelperMacros.h>
0003 #include "FWCore/ParameterSet/interface/FileInPath.h"
0004 #include "correction.h"
0005 
0006 class test_correctionlib : public CppUnit::TestFixture {
0007   CPPUNIT_TEST_SUITE(test_correctionlib);
0008   CPPUNIT_TEST(checkAll);
0009   CPPUNIT_TEST_SUITE_END();
0010 
0011 public:
0012   void setUp() {}
0013   void tearDown() {}
0014   void checkAll();
0015 };
0016 
0017 CPPUNIT_TEST_SUITE_REGISTRATION(test_correctionlib);
0018 
0019 void test_correctionlib::checkAll() {
0020   edm::FileInPath testfile("PhysicsTools/Utilities/test/corrections.json");
0021   auto cset = correction::CorrectionSet::from_file(testfile.fullPath());
0022   CPPUNIT_ASSERT(cset->at("test corr"));
0023   CPPUNIT_ASSERT_THROW(cset->at("nonexistent"), std::out_of_range);
0024   auto corr = cset->at("test corr");
0025   CPPUNIT_ASSERT(corr->evaluate({12.0, "blah"}) == 1.1);
0026   CPPUNIT_ASSERT(corr->evaluate({31.0, "blah3"}) == 0.25 * 31.0 + std::exp(3.1));
0027 }