Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
msgpack_check_eq.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
barretenberg/common/log.hpp
"
4
#include "
msgpack.hpp
"
5
#include <cstddef>
6
#include <string_view>
7
8
namespace
msgpack
{
9
13
template
<msgpack_concepts::HasMsgPack T>
14
bool
msgpack_check_eq
(
const
T& v1,
const
T& v2,
const
std::string_view& error_message)
15
{
16
bool
had_error =
false
;
17
// hack: const_cast is used to allow the msgpack method to be called on const objects without doubling up the
18
// function definition.
19
const_cast<
T&
>
(v1).
msgpack
([&](
auto
&... args1) {
// NOLINT
20
const_cast<
T&
>
(v2).
msgpack
([&](
auto
&... args2) {
// NOLINT
21
// Capture args1 and args2 as const ref tuples and then iterate through each, comparing the values
22
auto
args1_tuple = std::tie(args1...);
23
auto
args2_tuple = std::tie(args2...);
24
constexpr
auto
size1 =
std::tuple_size
<
decltype
(args1_tuple)>
::value
;
25
const
char
* current_label =
""
;
26
constexpr_for<0, size1, 1>([&]<
size_t
i>() {
27
if
constexpr
(i % 2 == 0) {
28
current_label =
std::get<i>
(args1_tuple);
29
}
else
{
30
auto
arg1 =
std::get<i>
(args1_tuple);
31
auto
arg2 =
std::get<i>
(args2_tuple);
32
if
(arg1 != arg2) {
33
if
(!had_error) {
34
info
(error_message);
35
}
36
had_error =
true
;
37
info
(current_label,
": "
, arg1,
" != "
, arg2);
38
}
39
}
40
});
41
});
42
});
43
return
!had_error;
44
}
45
}
// namespace msgpack
log.hpp
info
#define info(...)
Definition
log.hpp:93
value
FF value
Definition
indexed_tree_check.test.cpp:69
msgpack.hpp
msgpack
Definition
msgpack_apply.hpp:7
msgpack::msgpack_check_eq
bool msgpack_check_eq(const T &v1, const T &v2, const std::string_view &error_message)
Ensures that two msgpack objects are equal by applying the msgpack method to both and comparing the r...
Definition
msgpack_check_eq.hpp:14
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
src
barretenberg
serialize
msgpack_check_eq.hpp
Generated by
1.9.8