File indexing completed on 2024-04-06 12:24:23
0001 #include <cppunit/extensions/HelperMacros.h>
0002 #include "PhysicsTools/Utilities/interface/Parameter.h"
0003 #include <cmath>
0004
0005 class testParameter : public CppUnit::TestFixture {
0006 CPPUNIT_TEST_SUITE(testParameter);
0007 CPPUNIT_TEST(checkAll);
0008 CPPUNIT_TEST_SUITE_END();
0009
0010 public:
0011 void setUp() {}
0012 void tearDown() {}
0013 void checkAll();
0014 };
0015
0016 CPPUNIT_TEST_SUITE_REGISTRATION(testParameter);
0017
0018 void testParameter::checkAll() {
0019 double aVal = 123;
0020 std::string aName = "a";
0021 funct::Parameter a(aName, aVal);
0022 CPPUNIT_ASSERT(a.name() == aName);
0023 CPPUNIT_ASSERT(a.value() == aVal);
0024 double av = a;
0025 CPPUNIT_ASSERT(av == aVal);
0026 std::shared_ptr<double> ap = a;
0027 CPPUNIT_ASSERT(*ap == aVal);
0028 aVal = 234;
0029 a = aVal;
0030 CPPUNIT_ASSERT(a.value() == aVal);
0031 funct::Parameter a1 = a;
0032 CPPUNIT_ASSERT(a.value() == a1.value());
0033 CPPUNIT_ASSERT(a.name() == a1.name());
0034 a = 567;
0035 CPPUNIT_ASSERT(a.value() == a1.value());
0036 a1 = 123;
0037 CPPUNIT_ASSERT(a.value() == a1.value());
0038 }