Document the new DPF surfaces in one command set, and test the field, half-tree, and multipoint edges.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 23:18:10 -06:00
parent 0d8a5a8131
commit 0dff6df8ed
250 changed files with 12199 additions and 1981 deletions

57
test/tests/fp61_test.cpp Normal file
View file

@ -0,0 +1,57 @@
#include <gtest/gtest.h>
#include <cstdint>
#include <limits>
#include <sstream>
#include "dpf/fp61.hpp"
namespace
{
using dpf::fp61;
using dpf::fp61_mod;
} // namespace
TEST(Fp61, ReduceCanonicalizesTheModulus)
{
EXPECT_EQ(fp61::reduce(0), 0u);
EXPECT_EQ(fp61::reduce(1), 1u);
EXPECT_EQ(fp61::reduce(fp61_mod), 0u);
EXPECT_EQ(fp61::reduce(fp61_mod + 1), 1u);
EXPECT_EQ(fp61::reduce(std::uint64_t{1} << 61), 1u);
EXPECT_EQ(fp61::reduce(std::numeric_limits<std::uint64_t>::max()), 7u);
EXPECT_EQ(fp61::reduce(fp61::reduce(fp61_mod + 9)), fp61::reduce(9));
}
TEST(Fp61, ArithmeticWrapsInTheField)
{
const fp61 a{fp61_mod - 1};
const fp61 b{3};
EXPECT_EQ((a + b).raw(), 2u);
EXPECT_EQ((b - a).raw(), 4u);
EXPECT_EQ((-a).raw(), 1u);
EXPECT_EQ((-fp61{0}).raw(), 0u);
EXPECT_EQ((a - a).raw(), 0u);
EXPECT_EQ((-(-a)).raw(), a.raw());
EXPECT_EQ((a * fp61{1}).raw(), a.raw());
EXPECT_EQ((a * fp61{0}).raw(), 0u);
EXPECT_EQ((fp61{2} * fp61{3}).raw(), 6u);
}
TEST(Fp61, MultiplicationDistributes)
{
const fp61 a{1000};
const fp61 b{fp61_mod - 5};
const fp61 c{17};
EXPECT_EQ(((a + b) * c).raw(), (a * c + b * c).raw());
EXPECT_EQ((a * b).raw(), (b * a).raw());
}
TEST(Fp61, StreamPrintsTheReducedValue)
{
std::ostringstream os;
os << fp61{fp61_mod + 4};
EXPECT_EQ(os.str(), "4");
}