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
19using o2::mch::Error;
23
24BOOST_AUTO_TEST_CASE(DefaultErrorMapShouldBeEmpty)
25{
26 ErrorMap em;
29}
30
31BOOST_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);
38}
39
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});
48 BOOST_CHECK_EQUAL(em.getNumberOfErrors(ErrorType{0}), 4);
49 BOOST_CHECK_EQUAL(em.getNumberOfErrors(ErrorGroup{0}), 6);
50}
51
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);
63}
64
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 });
91}
A container class to summarize errors encountered during processing.
Definition ErrorMap.h:38
void forEach(ErrorFunction f) const
Definition ErrorMap.cxx:90
uint64_t getNumberOfErrors() const
Definition ErrorMap.cxx:63
void add(ErrorType errorType, uint32_t id0, uint32_t id1, uint64_t n=1)
Definition ErrorMap.cxx:33
uint64_t getNumberOfErrorTypes() const
Definition ErrorMap.h:55
GLdouble n
Definition glcorearb.h:1982
GLdouble f
Definition glcorearb.h:310
ErrorGroup
Definition Error.h:31
ErrorType
Definition Error.h:54
BOOST_AUTO_TEST_CASE(DefaultErrorMapShouldBeEmpty)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())