AliRoot Core  edcc906 (edcc906)
TestsAliEMCALTriggerTRUDCSConfig.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <cstdlib>
28 #include <bitset>
29 #include <iostream>
30 #include <sstream>
31 #include <string>
32 
34 
35 namespace EMCAL {
36  namespace Base {
37  namespace Tests {
38  namespace TestAliEMCALTriggerTRUDCSConfig {
39 
48  testobject.SetSELPF(7711);
49  testobject.SetL0SEL(1);
50  testobject.SetL0COSM(100);
51  testobject.SetGTHRL0(132);
52  testobject.SetMaskReg(1024, 0);
53  testobject.SetMaskReg(0, 1);
54  testobject.SetMaskReg(512, 2);
55  testobject.SetMaskReg(31985, 3);
56  testobject.SetMaskReg(0, 4);
57  testobject.SetMaskReg(0, 5);
58  testobject.SetRLBKSTU(0);
59  testobject.SetFw(0x21);
60  }
61 
71  bool TestEqualSelf(){
72  AliEMCALTriggerTRUDCSConfig testobject;
73  ConfigureReference(testobject);
74 
75  // Make test
76  return testobject == testobject;
77  }
78 
88  bool TestEqualTrue(){
90  ConfigureReference(test1);
91  ConfigureReference(test2);
92  return test1 == test2;
93  }
94 
107  AliEMCALTriggerTRUDCSConfig ref, testobject;
108  std::bitset<8> testresult; // bit set in case test fails (operator returns true)
109  testresult.reset();
110 
111  // Configure reference
112  ConfigureReference(ref);
113 
114  // Variation peak finder
115  ConfigureReference(testobject);
116  testobject.SetSELPF(7000);
117  testresult.set(0, ref == testobject);
118 
119  // Variation L0 Algorithm
120  ConfigureReference(testobject);
121  testobject.SetL0SEL(2);
122  testresult.set(1, ref == testobject);
123 
124  // Variation cosmic threshold
125  ConfigureReference(testobject);
126  testobject.SetL0COSM(1000);
127  testresult.set(2, ref == testobject);
128 
129  // Variation global threshold
130  ConfigureReference(testobject);
131  testobject.SetGTHRL0(184);
132  testresult.set(3, ref == testobject);
133 
134  // Variation Rollback
135  ConfigureReference(testobject);
136  testobject.SetRLBKSTU(1);
137  testresult.set(4, ref == testobject);
138 
139  // Variation Firmware
140  ConfigureReference(testobject);
141  testobject.SetFw(0x11);
142  testresult.set(5, ref == testobject);
143 
144  // Variation Mask
145  ConfigureReference(testobject);
146  testobject.SetMaskReg(768,0);
147  testobject.SetMaskReg(15,1);
148  testobject.SetMaskReg(37632,2);
149  testobject.SetMaskReg(63,3);
150  testobject.SetMaskReg(0,4);
151  testobject.SetMaskReg(208,5);
152  testresult.set(5, ref == testobject);
153 
154  return !testresult.any();
155  }
156 
167  bool TestStream(){
168  std::string reference = std::string("SELPF: 1e1f, L0SEL: 1, L0COSM: 100, GTHRL0: 132, RLBKSTU: 0, FW: 21\n")
169  + std::string("Reg0: 00000000000000000000010000000000\nReg1: 00000000000000000000000000000000\n")
170  + std::string("Reg2: 00000000000000000000001000000000\nReg3: 00000000000000000111110011110001\n")
171  + std::string("Reg4: 00000000000000000000000000000000\nReg5: 00000000000000000000000000000000\n");
172 
174  ConfigureReference(test);
175  std::stringstream testmaker;
176  testmaker << test;
177  return testmaker.str() == reference;
178  }
179  }
180  }
181  }
182 }
183 
193 int main(int argc, char **argv) {
194  int npass(0);
196  npass++;
197  } else {
198  std::cerr << "Failure eq_self" << std::endl;
199  }
201  npass++;
202  } else {
203  std::cerr << "Failure_eq_true" << std::endl;
204  }
206  npass++;
207  } else {
208  std::cerr << "Failure_eq_false" << std::endl;
209  }
211  npass++;
212  } else {
213  std::cerr << "Failure_stream" << std::endl;
214  }
215  std::cout << "Passing " << npass << "/4" << std::endl;
216  if(npass == 4) return EXIT_SUCCESS;
217  return EXIT_FAILURE;
218 }
void SetMaskReg(UInt_t msk, Int_t pos)
int main(int argc, char **argv)
Test runner for tests of class AliEMCALTriggerTRUDCSConfig.
void ConfigureReference(AliEMCALTriggerTRUDCSConfig &testobject)
Apply reference configuration.
void test1()
bool TestEqualFalse()
Test for operator== on different objects.
void test()
Definition: interpolTest.C:100
void test2()