Project
Loading...
Searching...
No Matches
test_BigEndian.cxx
Go to the documentation of this file.
1
// Copyright 2019-2026 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
#include "
Framework/BigEndian.h
"
13
#include <catch_amalgamated.hpp>
14
#include <cstdint>
15
#include <cstring>
16
17
using namespace
o2::framework
;
18
19
TEST_CASE
(
"bigEndianCopy: typeSize 1 is a plain copy"
)
20
{
21
alignas
(64) uint8_t dest[64] = {};
22
uint8_t
src
[4] = {0x01, 0x02, 0x03, 0x04};
23
bigEndianCopy
(dest,
src
, 4, 1);
24
REQUIRE(std::memcmp(dest,
src
, 4) == 0);
25
}
26
27
TEST_CASE
(
"bigEndianCopy: uint16 byte swap"
)
28
{
29
alignas
(64) uint8_t dest[64] = {};
30
uint8_t
src
[2] = {0xCA, 0xFE};
// big-endian 0xCAFE
31
bigEndianCopy
(dest,
src
, 1, 2);
32
uint16_t
result
;
33
std::memcpy(&
result
, dest, 2);
34
REQUIRE(
result
== 0xCAFE);
35
}
36
37
TEST_CASE
(
"bigEndianCopy: uint32 byte swap"
)
38
{
39
alignas
(64) uint8_t dest[64] = {};
40
uint8_t
src
[4] = {0xDE, 0xAD, 0xBE, 0xEF};
// big-endian 0xDEADBEEF
41
bigEndianCopy
(dest,
src
, 1, 4);
42
uint32_t
result
;
43
std::memcpy(&
result
, dest, 4);
44
REQUIRE(
result
== 0xDEADBEEF);
45
}
46
47
TEST_CASE
(
"bigEndianCopy: uint64 byte swap"
)
48
{
49
alignas
(64) uint8_t dest[64] = {};
50
uint8_t
src
[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
51
bigEndianCopy
(dest,
src
, 1, 8);
52
uint64_t
result
;
53
std::memcpy(&
result
, dest, 8);
54
REQUIRE(
result
== 0x0123456789ABCDEFULL);
55
}
56
57
TEST_CASE
(
"bigEndianCopy: multiple elements"
)
58
{
59
alignas
(64) uint8_t dest[64] = {};
60
uint8_t
src
[8] = {0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04};
61
bigEndianCopy
(dest,
src
, 4, 2);
62
auto
* p =
reinterpret_cast<
uint16_t*
>
(dest);
63
REQUIRE(p[0] == 1);
64
REQUIRE(p[1] == 2);
65
REQUIRE(p[2] == 3);
66
REQUIRE(p[3] == 4);
67
}
BigEndian.h
src
GLenum src
Definition
glcorearb.h:1767
result
GLuint64EXT * result
Definition
glcorearb.h:5662
o2::framework
Defining ITS Vertex explicitly as messageable.
Definition
Cartesian.h:288
o2::framework::TEST_CASE
TEST_CASE("test_prepareArguments")
Definition
test_DeviceSpecHelpers.cxx:102
o2::framework::bigEndianCopy
void bigEndianCopy(void *dest, const void *src, int count, size_t typeSize)
Definition
BigEndian.h:26
Framework
Foundation
test
test_BigEndian.cxx
Generated on Sun Apr 26 2026 06:43:34 for Project by
1.9.8