Belle II Software  release-08-01-10
VxdID.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <vxd/dataobjects/VxdID.h>
9 #include <gtest/gtest.h>
10 #include <string>
11 
12 using namespace std;
13 
14 namespace Belle2 {
21  TEST(VxdID, Constructor)
22  {
23  VxdID s("1.1.1");
24  VxdID l(1, 1, 1);
25  EXPECT_EQ(l, s);
26  EXPECT_EQ((string)l, "1.1.1");
27  }
28 
30  TEST(VxdID, FromString)
31  {
32  //Check that all possible values can be converted back and forth
33  for (int layer = 0; layer <= VxdID::MaxLayer; ++layer) {
34  for (int ladder = 0; ladder <= VxdID::MaxLadder; ++ladder) {
35  for (int sensor = 0; sensor <= VxdID::MaxSensor; ++sensor) {
36  for (int segment = 0; segment <= VxdID::MaxSegment; ++segment) {
37  string sid = (string)VxdID(layer, ladder, sensor, segment);
38  VxdID id(layer, ladder, sensor, segment);
39  EXPECT_EQ(id, VxdID(sid));
40  EXPECT_EQ(id.getLayerNumber(), layer);
41  EXPECT_EQ(id.getLadderNumber(), ladder);
42  EXPECT_EQ(id.getSensorNumber(), sensor);
43  EXPECT_EQ(id.getSegmentNumber(), segment);
44  }
45  }
46  }
47  }
48 
49  //Check some invalid ids
50  EXPECT_THROW(VxdID("1.f"), invalid_argument);
51  EXPECT_THROW(VxdID("1.1.f"), invalid_argument);
52  EXPECT_THROW(VxdID("1.*.f"), invalid_argument);
53  EXPECT_THROW(VxdID("1.1.1 and some more"), invalid_argument);
54  }
56 } // namespace
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
TEST(VxdID, FromString)
Check the string conversion of the VxdID in both directions.
Definition: VxdID.cc:30
Abstract base class for different kinds of events.