CbmRoot
Loading...
Searching...
No Matches
_GTestCbmDefs.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmDetectorList.h"
6
7#include <TString.h>
8
9#include <iostream>
10
11#include <gtest/gtest-spi.h>
12#include <gtest/gtest.h>
13using std::cout;
14using std::endl;
15
16// Structure to pass filenames together with expected response into the
17// parametrized test
19 DetectorId detIdFromEnum;
20 int detId;
21 TString detName;
23};
24
25// Base class to use the same basic setup for parameterized and
26// non-parameterized tests
27// Here one defines everything which is common for all the different
28// test cases
29template<class T>
30class _TestCbmDetectorListBase : public T {
31protected:
32 CbmDetectorList fList;
33
34
35 virtual void SetUp() {}
36
37 virtual void TearDown() {}
38};
39
40// This is the derived class for the non-parameterized test cases.
41class CbmDetectorListTest : public _TestCbmDetectorListBase<testing::Test> {
42};
43
44// This is the derived class for the parameterized test cases.
45class CbmDetectorListParamTest : public _TestCbmDetectorListBase<testing::TestWithParam<InOutStructure>> {
46protected:
47 DetectorId detIdFromEnum;
48 int32_t detId;
49 TString detName;
51
52 virtual void SetUp()
53 {
54 InOutStructure const& p = GetParam();
55
57 detId = p.detId;
58 detName = p.detName;
60 }
61};
62
63TEST(CbmDetectorList, outOfBounds)
64{
65 CbmDetectorList fList;
66 TString retName;
67
68 fList.GetSystemName(111, retName);
69 EXPECT_EQ("unknown", retName);
70
71 fList.GetSystemName(-111, retName);
72 EXPECT_EQ("unknown", retName);
73
74 fList.GetSystemNameCaps(111, retName);
75 EXPECT_EQ("unknown", retName);
76
77 fList.GetSystemNameCaps(-111, retName);
78 EXPECT_EQ("UNKNOWN", retName);
79}
80
81TEST_P(CbmDetectorListParamTest, checkUniqueIdCreation)
82{
83 TString retName;
84 fList.GetSystemName(detIdFromEnum, retName);
85 EXPECT_EQ(detName, retName);
86
87 fList.GetSystemName(detId, retName);
88 EXPECT_EQ(detName, retName);
89
90 fList.GetSystemNameCaps(detIdFromEnum, retName);
91 EXPECT_EQ(detNameUppercase, retName);
92
93 fList.GetSystemNameCaps(detId, retName);
94 EXPECT_EQ(detNameUppercase, retName);
95}
96
97InOutStructure val1 = {kREF, 0, "ref", "REF"};
98InOutStructure val2 = {kMVD, 1, "mvd", "MVD"};
99InOutStructure val3 = {kSTS, 2, "sts", "STS"};
100InOutStructure val4 = {kRICH, 3, "rich", "RICH"};
101InOutStructure val5 = {kMUCH, 4, "much", "MUCH"};
102InOutStructure val6 = {kTRD, 5, "trd", "TRD"};
103InOutStructure val7 = {kTOF, 6, "tof", "TOF"};
104InOutStructure val8 = {kECAL, 7, "ecal", "ECAL"};
105InOutStructure val9 = {kPSD, 8, "unknown", "PSD"};
106InOutStructure val10 = {kSTT, 9, "unknown", "UNKNOWN"};
107InOutStructure val11 = {kFHODO, 10, "fhodo", "FHODO"};
108InOutStructure val12 = {kTutDet, 11, "tutdet", "TUTDET"};
109InOutStructure val13 = {kNOFDETS, 12, "unknown", "UNKNOWN"};
110
112 ::testing::Values(val1, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12));
@ kSTS
Local tracking in CBM (STS + MVD), results stored to the StsTrack branch.
InOutStructure val6
InOutStructure val4
InOutStructure val1
InOutStructure val8
InOutStructure val13
InOutStructure val5
InOutStructure val9
InOutStructure val12
InOutStructure val7
TEST(CbmDetectorList, outOfBounds)
InOutStructure val3
INSTANTIATE_TEST_CASE_P(TestAllParameters, CbmDetectorListParamTest, ::testing::Values(val1, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12))
InOutStructure val11
TEST_P(CbmDetectorListParamTest, checkUniqueIdCreation)
InOutStructure val10
InOutStructure val2
TString detNameUppercase
DetectorId detIdFromEnum