Project
Loading...
Searching...
No Matches
testDsElecId.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test MCHRaw DsElecId
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
17
19#include <fmt/format.h>
20
21using namespace o2::mch::raw;
22
23BOOST_AUTO_TEST_SUITE(o2_mch_raw)
24
25BOOST_AUTO_TEST_SUITE(dselecid)
26
28{
29 o2::mch::raw::DsElecId eid(448, 6, 2);
30 BOOST_CHECK_EQUAL(asString(eid), "S448-J6-DS2");
31 auto code = encode(eid);
32 auto x = decodeDsElecId(code);
33 BOOST_CHECK_EQUAL(code, encode(x.value()));
34}
35
36BOOST_AUTO_TEST_CASE(DsElecIdTooBigSolarIdShouldThrow)
37{
38 BOOST_CHECK_THROW(o2::mch::raw::DsElecId eid(1024, 0, 1), std::invalid_argument);
40}
41
42BOOST_AUTO_TEST_CASE(DsElecIdValidString)
43{
44 o2::mch::raw::DsElecId eid(448, 6, 2);
45 auto x = decodeDsElecId("S448-J6-DS2");
46 BOOST_CHECK_EQUAL(x.has_value(), true);
47 BOOST_CHECK_EQUAL(encode(eid), encode(x.value()));
48}
49
50BOOST_AUTO_TEST_CASE(DecodeDsElecIdForTooShortString)
51{
52 BOOST_CHECK_EQUAL(decodeDsElecId("S448").has_value(), false);
53 BOOST_CHECK_EQUAL(decodeDsElecId("S448-XX").has_value(), false);
54 BOOST_CHECK_EQUAL(decodeDsElecId("S448-J3-DS2-CH-0").has_value(), true);
55}
56
57BOOST_AUTO_TEST_CASE(DecodeDsElecIdForInvalidSolar)
58{
59 BOOST_CHECK_EQUAL(decodeDsElecId("s448-J6-DS2").has_value(), false);
60 BOOST_CHECK_EQUAL(decodeDsElecId("448-J6-DS2").has_value(), false);
61 BOOST_CHECK_EQUAL(decodeDsElecId("X448-J6-DS2").has_value(), false);
62}
63
64BOOST_AUTO_TEST_CASE(DecodeDsElecIdForInvalidGroup)
65{
66 BOOST_CHECK_EQUAL(decodeDsElecId("S448-6-DS2").has_value(), false);
67 BOOST_CHECK_EQUAL(decodeDsElecId("S448-j6-DS2").has_value(), false);
68 BOOST_CHECK_EQUAL(decodeDsElecId("S448-X6-DS2").has_value(), false);
69}
70
71BOOST_AUTO_TEST_CASE(DecodeDsElecIdForInvalidDS)
72{
73 BOOST_CHECK_EQUAL(decodeDsElecId("S448-J6-DS").has_value(), false);
74 BOOST_CHECK_EQUAL(decodeDsElecId("S448-J6-Ds2").has_value(), false);
75 BOOST_CHECK_EQUAL(decodeDsElecId("S448-J6-D2").has_value(), false);
76}
77
78BOOST_AUTO_TEST_CASE(DecodeChannelIdForInvalidString)
79{
80 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2").has_value(), false);
81 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-CH-0").has_value(), false);
82 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-cH-0").has_value(), false);
83 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-XX-0").has_value(), false);
84 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-XX0").has_value(), false);
85 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-ch0").has_value(), false);
86}
87
88BOOST_AUTO_TEST_CASE(DecodeChannelIdForValidString)
89{
90 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-CH0").has_value(), true);
91 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-CH63").has_value(), true);
92}
93
94BOOST_AUTO_TEST_CASE(DecodeChannelIdForInvalidChannel)
95{
96 BOOST_CHECK_EQUAL(decodeChannelId("S448-J6-DS2-CH64").has_value(), false);
97}
98
99BOOST_AUTO_TEST_SUITE_END()
100BOOST_AUTO_TEST_SUITE_END()
GLint GLenum GLint x
Definition glcorearb.h:403
std::optional< uint8_t > decodeChannelId(std::string rep)
Definition DsElecId.cxx:84
std::string asString(const SampaCluster &sc)
std::optional< DsElecId > decodeDsElecId(uint32_t code)
Definition DsElecId.cxx:37
uint32_t encode(const DsDetId &id)
Create an integer code for the given id.
Definition DsDetId.cxx:28
BOOST_AUTO_TEST_CASE(FlatHisto)
BOOST_CHECK_NO_THROW(algorithm::merge(target, other))
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())