-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathalignment.cpp
37 lines (29 loc) · 1.19 KB
/
alignment.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Copyright (c) 2017-2025, Hans Erik Thrane */
#include <catch2/catch_all.hpp>
#include "roq/api.hpp"
using namespace roq;
TEST_CASE("alignment_layer", "[alignment]") {
std::array<Layer, 2> value;
auto offset = reinterpret_cast<uint8_t *>(&value[1]) - reinterpret_cast<uint8_t *>(&value[0]);
CHECK(offset == std::ptrdiff_t{32});
}
TEST_CASE("alignment_mbp_update", "[alignment]") {
std::array<MBPUpdate, 2> value;
auto offset = reinterpret_cast<uint8_t *>(&value[1]) - reinterpret_cast<uint8_t *>(&value[0]);
CHECK(offset == std::ptrdiff_t{32});
}
TEST_CASE("alignment_mbo_update", "[alignment]") {
std::array<MBOUpdate, 2> value;
auto offset = reinterpret_cast<uint8_t *>(&value[1]) - reinterpret_cast<uint8_t *>(&value[0]);
CHECK(offset == std::ptrdiff_t{64});
}
TEST_CASE("alignment_trade", "[alignment]") {
std::array<Trade, 2> value;
auto offset = reinterpret_cast<uint8_t *>(&value[1]) - reinterpret_cast<uint8_t *>(&value[0]);
CHECK(offset == std::ptrdiff_t{192});
}
TEST_CASE("alignment_fill", "[alignment]") {
std::array<Fill, 2> value;
auto offset = reinterpret_cast<uint8_t *>(&value[1]) - reinterpret_cast<uint8_t *>(&value[0]);
CHECK(offset == std::ptrdiff_t{120});
}