Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
relation_types.test.cpp
Go to the documentation of this file.
1#include "relation_types.hpp"
4
5#include <gtest/gtest.h>
6
7using namespace bb;
8
9TEST(RelationTypes, CreateSumcheckTupleOfTuplesOfUnivariates)
10{
11 using FF = fr;
12
13 struct Relation1 {
14 using SumcheckTupleOfUnivariatesOverSubrelations =
15 TupleOfUnivariates<FF, /*SUBRELATION_PARTIAL_LENGTHS=*/std::array<size_t, 1>{ 3 }>;
16 };
17 struct Relation2 {
18 using SumcheckTupleOfUnivariatesOverSubrelations =
19 TupleOfUnivariates<FF, /*SUBRELATION_PARTIAL_LENGTHS=*/std::array<size_t, 2>{ 2, 5 }>;
20 };
21 using RelationsTuple = flat_tuple::tuple<Relation1, Relation2>;
22 auto tuple_of_tuples = create_sumcheck_tuple_of_tuples_of_univariates<RelationsTuple>();
23
24 Univariate<FF, 3> expected_zero_1({ 0, 0, 0 });
25 Univariate<FF, 2> expected_zero_2({ 0, 0 });
26 Univariate<FF, 5> expected_zero_3({ 0, 0, 0, 0, 0 });
27 EXPECT_EQ(std::get<0>(std::get<0>(tuple_of_tuples)), expected_zero_1);
28 EXPECT_EQ(std::get<0>(std::get<1>(tuple_of_tuples)), expected_zero_2);
29 EXPECT_EQ(std::get<1>(std::get<1>(tuple_of_tuples)), expected_zero_3);
30
31 // Now test it when creating it from the type.
32 using SumcheckTupleOfTuplesOfUnivariates =
33 decltype(create_sumcheck_tuple_of_tuples_of_univariates<RelationsTuple>());
34 // Note: {} is required to initialize the tuple contents. Otherwise the univariates contain garbage.
35 SumcheckTupleOfTuplesOfUnivariates tuple_of_tuples_from_type{};
36
37 EXPECT_EQ(std::get<0>(std::get<0>(tuple_of_tuples_from_type)), expected_zero_1);
38 EXPECT_EQ(std::get<0>(std::get<1>(tuple_of_tuples_from_type)), expected_zero_2);
39 EXPECT_EQ(std::get<1>(std::get<1>(tuple_of_tuples_from_type)), expected_zero_3);
40}
41
42// This class needs to be outside the test because of the templated skip.
44 struct AllEntities {
45 int input;
46 };
47 template <typename Entities> static bool skip(const Entities&) { return false; }
48};
49
50TEST(RelationTypes, IsSkippableConcept)
51{
52 // Works with a non-templated skip function.
53 struct Relation1 {
54 struct AllEntities {
55 int input;
56 };
57 static bool skip(const AllEntities&) { return false; }
58 };
59 static_assert(isSkippable<Relation1, Relation1::AllEntities>);
60
61 // Works with a templated skip function.
62 static_assert(isSkippable<RelationWithTemplatedSkip, RelationWithTemplatedSkip::AllEntities>);
63
64 // False when the skip function is not there.
65 struct Relation2 {
66 struct AllEntities {
67 int input;
68 };
69 };
70 static_assert(!isSkippable<Relation2, Relation2::AllEntities>);
71
72 struct Relation3 {};
73}
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
Entry point for Barretenberg command-line interface.
TEST(MegaCircuitBuilder, CopyConstructor)
typename Flavor::FF FF
field< Bn254FrParams > fr
Definition fr.hpp:174
typename TupleOfContainersOverArray< bb::Univariate, FF, LENGTHS, 0, 0 >::type TupleOfUnivariates
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static bool skip(const Entities &)