Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:33

0001 #include <cppunit/extensions/HelperMacros.h>
0002 #include "PhysicsTools/Utilities/interface/Variables.h"
0003 #include "PhysicsTools/Utilities/interface/Operations.h"
0004 
0005 class testVariables : public CppUnit::TestFixture {
0006   CPPUNIT_TEST_SUITE(testVariables);
0007   CPPUNIT_TEST(checkAll);
0008   CPPUNIT_TEST_SUITE_END();
0009 
0010 public:
0011   void setUp() {}
0012   void tearDown() {}
0013   void checkAll();
0014 };
0015 
0016 DEFINE_VARIABLE(W, "w");
0017 IMPLEMENT_VARIABLE(W);
0018 
0019 CPPUNIT_TEST_SUITE_REGISTRATION(testVariables);
0020 
0021 void testVariables::checkAll() {
0022   double value = 1.234, value1 = 2.345;
0023   funct::X x;
0024   x = value;
0025   double v = x;
0026   CPPUNIT_ASSERT(v == value);
0027   CPPUNIT_ASSERT(x() == v);
0028   x.set(value1);
0029   v = x;
0030   CPPUNIT_ASSERT(v == value1);
0031   CPPUNIT_ASSERT(x() == v);
0032 
0033   funct::W w;
0034   w = value;
0035   v = w;
0036   CPPUNIT_ASSERT(v == value);
0037   CPPUNIT_ASSERT(w() == v);
0038 
0039   funct::Y y;
0040 
0041   x = value;
0042   y = value1;
0043   double z;
0044   z = x + y;
0045   CPPUNIT_ASSERT(z = value + value1);
0046   z = x - y;
0047   CPPUNIT_ASSERT(z = value - value1);
0048   z = x * y;
0049   CPPUNIT_ASSERT(z = value * value1);
0050   z = x / y;
0051   CPPUNIT_ASSERT(z = value / value1);
0052   z = x ^ y;
0053   CPPUNIT_ASSERT(z = pow(value, value1));
0054   z = -x;
0055   CPPUNIT_ASSERT(z = -value);
0056 }