Project
Loading...
Searching...
No Matches
testElinkEncoder.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 ElinkEncoder
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
17#include <iostream>
18#include "BareElinkEncoder.h"
21#include <fstream>
22#include <fmt/printf.h>
23#include <boost/mpl/list.hpp>
24
25using namespace o2::mch::raw;
26
27BOOST_AUTO_TEST_SUITE(o2_mch_raw)
28
29BOOST_AUTO_TEST_SUITE(elinkencoder)
30
32
33BOOST_AUTO_TEST_CASE_TEMPLATE(CtorMustHaveElinkIdBetween0And39, T, testTypes)
34{
35 using Encoder = ElinkEncoder<T, ChargeSumMode>;
36 BOOST_CHECK_THROW(Encoder enc(40), std::invalid_argument);
37 BOOST_CHECK_NO_THROW(Encoder enc(39));
38}
39
40BOOST_AUTO_TEST_CASE_TEMPLATE(AddEmptyDataShouldThrow, T, testTypes)
41{
43 std::vector<SampaCluster> data;
44 BOOST_CHECK_THROW(enc.addChannelData(31, data), std::invalid_argument);
45}
46
47BOOST_AUTO_TEST_CASE_TEMPLATE(AddMixedDataShouldThrow, T, testTypes)
48{
50 std::vector<SampaCluster> data;
51 std::vector<uint16_t> samples{123, 456, 789};
52 data.emplace_back(0, 0, 1000, 1001);
53 data.emplace_back(0, 0, samples);
54 BOOST_CHECK_THROW(enc.addChannelData(31, data), std::invalid_argument);
55}
56
57BOOST_AUTO_TEST_CASE_TEMPLATE(ChannelIdIsBetween0And63, T, testTypes)
58{
60 std::vector<SampaCluster> data = {SampaCluster(20, 21, 10, 11)};
61
62 BOOST_CHECK_THROW(enc.addChannelData(64, data),
63 std::invalid_argument);
64 BOOST_CHECK_NO_THROW(enc.addChannelData(63, data));
65}
66
67BOOST_AUTO_TEST_SUITE_END()
68BOOST_AUTO_TEST_SUITE_END()
GLboolean * data
Definition glcorearb.h:298
Definition list.h:40
Piece of data for one Sampa channel.
boost::mpl::list< o2::dcs::DataPointIdentifier, o2::dcs::DataPointValue, o2::dcs::DataPointCompositeObject > testTypes
BOOST_AUTO_TEST_CASE_TEMPLATE(CtorMustHaveElinkIdBetween0And39, T, testTypes)
BOOST_CHECK_NO_THROW(algorithm::merge(target, other))