Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:41

0001 #include <cppunit/TestFixture.h>
0002 #include <cppunit/extensions/HelperMacros.h>
0003 #include <cppunit/TestResult.h>
0004 #include <cppunit/TestRunner.h>
0005 #include <cppunit/ui/text/TestRunner.h>
0006 #include <cppunit/TestResultCollector.h>
0007 #include <cppunit/TextTestProgressListener.h>
0008 #include <cppunit/CompilerOutputter.h>
0009 
0010 #include "CondFormats/SiStripObjects/interface/SiStripConfObject.h"
0011 
0012 class TestSiStripConfObject : public CppUnit::TestFixture {
0013 public:
0014   TestSiStripConfObject() {}
0015 
0016   void setUp() {}
0017 
0018   void tearDown() {}
0019 
0020   void testPutAndGet() {
0021     CPPUNIT_ASSERT(conf.put("par1", 1) == true);
0022     CPPUNIT_ASSERT(conf.put("par2", 1.1) == true);
0023     CPPUNIT_ASSERT(conf.put("par3", "one") == true);
0024 
0025     CPPUNIT_ASSERT(conf.get<int>("par1") == 1);
0026     CPPUNIT_ASSERT(conf.get<float>("par2") == float(1.1));
0027     CPPUNIT_ASSERT(conf.get<std::string>("par3") == "one");
0028 
0029     // std::cout << "par1 int = " << conf.get<int>("par1") << std::endl;
0030     // std::cout << "par1 float = " << conf.get<float>("par1") << std::endl;
0031     // std::cout << "par1 string = " << conf.get<std::string>("par1") << std::endl;
0032 
0033     // std::cout << "par2 int = " << conf.get<int>("par2") << std::endl;
0034     // std::cout << "par2 float = " << conf.get<float>("par2") << std::endl;
0035     // std::cout << "par2 string = " << conf.get<std::string>("par2") << std::endl;
0036 
0037     // std::cout << "par3 int = " << conf.get<int>("par3") << std::endl;
0038     // std::cout << "par3 float = " << conf.get<float>("par3") << std::endl;
0039     // std::cout << "par3 string = " << conf.get<std::string>("par3") << std::endl;
0040 
0041     // Insertion of already existing parameter
0042     CPPUNIT_ASSERT(conf.put("par1", 2) == false);
0043 
0044     // Check if the parameter is there
0045     CPPUNIT_ASSERT(conf.isParameter("par1"));
0046     CPPUNIT_ASSERT(conf.isParameter("par2"));
0047     CPPUNIT_ASSERT(conf.isParameter("par3"));
0048     CPPUNIT_ASSERT(!(conf.isParameter("par4")));
0049   }
0050 
0051   CPPUNIT_TEST_SUITE(TestSiStripConfObject);
0052   CPPUNIT_TEST(testPutAndGet);
0053   CPPUNIT_TEST_SUITE_END();
0054 
0055   SiStripConfObject conf;
0056 };
0057 
0058 CPPUNIT_TEST_SUITE_REGISTRATION(TestSiStripConfObject);