Project
Loading...
Searching...
No Matches
testErrorMap.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 errormap test
13
#define BOOST_TEST_MAIN
14
#define BOOST_TEST_DYN_LINK
15
#include <boost/test/unit_test.hpp>
16
#include "
MCHBase/ErrorMap.h
"
17
#include <fmt/core.h>
18
19
using
o2::mch::Error
;
20
using
o2::mch::ErrorGroup
;
21
using
o2::mch::ErrorMap
;
22
using
o2::mch::ErrorType
;
23
24
BOOST_AUTO_TEST_CASE
(DefaultErrorMapShouldBeEmpty)
25
{
26
ErrorMap
em;
27
BOOST_CHECK_EQUAL
(em.
getNumberOfErrorTypes
(), 0);
28
BOOST_CHECK_EQUAL
(em.
getNumberOfErrors
(), 0);
29
}
30
31
BOOST_AUTO_TEST_CASE
(AddingErrorType)
32
{
33
ErrorMap
em;
34
em.
add
(ErrorType{0}, 0, 0);
35
em.
add
(ErrorType{1}, 0, 0);
36
em.
add
(ErrorType{2}, 0, 0);
37
BOOST_CHECK_EQUAL
(em.
getNumberOfErrorTypes
(), 3);
38
}
39
40
BOOST_AUTO_TEST_CASE
(AddingError)
41
{
42
ErrorMap
em;
43
em.
add
(ErrorType{0}, 0, 0);
44
em.
add
(ErrorType{1}, 0, 0, 2);
45
em.
add
(
Error
{ErrorType{0}, 1, 2, 3});
46
BOOST_CHECK_EQUAL
(em.
getNumberOfErrorTypes
(), 2);
47
BOOST_CHECK_EQUAL
(em.
getNumberOfErrors
(), 6);
48
BOOST_CHECK_EQUAL
(em.
getNumberOfErrors
(ErrorType{0}), 4);
49
BOOST_CHECK_EQUAL
(em.
getNumberOfErrors
(ErrorGroup{0}), 6);
50
}
51
52
BOOST_AUTO_TEST_CASE
(MergingError)
53
{
54
ErrorMap
em1;
55
em1.
add
(ErrorType{0}, 0, 0);
56
em1.
add
(ErrorType{1}, 0, 0);
57
ErrorMap
em2;
58
em2.
add
(ErrorType{0}, 1, 2);
59
em2.
add
(ErrorType{0}, 0, 0);
60
em2.
add
(em1);
61
BOOST_CHECK_EQUAL
(em2.
getNumberOfErrorTypes
(), 2);
62
BOOST_CHECK_EQUAL
(em2.
getNumberOfErrors
(), 4);
63
}
64
65
BOOST_AUTO_TEST_CASE
(ErrorFunction)
66
{
67
ErrorMap
em;
68
em.
add
(ErrorType{0}, 0, 0);
69
em.
add
(ErrorType{0}, 0, 0);
70
em.
add
(ErrorType{1}, 0, 0);
71
em.
add
(ErrorType{0}, 1, 2);
72
73
std::vector<std::string> lines;
74
auto
f
= [&lines](
Error
error) {
75
lines.emplace_back(fmt::format(
"ET {} ID [{},{}] seen {} time(s)"
,
76
static_cast<
uint32_t
>
(error.type), error.id0, error.id1, error.count));
77
};
78
em.
forEach
(
f
);
79
BOOST_REQUIRE_EQUAL(lines.size(), 3);
80
BOOST_CHECK_EQUAL
(lines[0],
"ET 0 ID [0,0] seen 2 time(s)"
);
81
BOOST_CHECK_EQUAL
(lines[1],
"ET 0 ID [1,2] seen 1 time(s)"
);
82
BOOST_CHECK_EQUAL
(lines[2],
"ET 1 ID [0,0] seen 1 time(s)"
);
83
84
uint64_t
n
(0);
85
em.
forEach
(ErrorType{0}, [&
n
](
Error
error) {
86
if
(error.id0 == 0) {
87
n
+= error.count;
88
}
89
});
90
BOOST_CHECK_EQUAL
(
n
, 2);
91
}
ErrorMap.h
o2::mch::ErrorMap
A container class to summarize errors encountered during processing.
Definition
ErrorMap.h:38
o2::mch::ErrorMap::forEach
void forEach(ErrorFunction f) const
Definition
ErrorMap.cxx:90
o2::mch::ErrorMap::getNumberOfErrors
uint64_t getNumberOfErrors() const
Definition
ErrorMap.cxx:63
o2::mch::ErrorMap::add
void add(ErrorType errorType, uint32_t id0, uint32_t id1, uint64_t n=1)
Definition
ErrorMap.cxx:33
o2::mch::ErrorMap::getNumberOfErrorTypes
uint64_t getNumberOfErrorTypes() const
Definition
ErrorMap.h:55
n
GLdouble n
Definition
glcorearb.h:1982
f
GLdouble f
Definition
glcorearb.h:310
o2::mch::ErrorGroup
ErrorGroup
Definition
Error.h:31
o2::mch::ErrorType
ErrorType
Definition
Error.h:54
o2::mch::Error
Definition
Error.h:69
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(DefaultErrorMapShouldBeEmpty)
Definition
testErrorMap.cxx:24
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
Detectors
MUON
MCH
Base
src
testErrorMap.cxx
Generated on Tue Feb 25 2025 23:16:22 for Project by
1.9.8