#include #include "concretelang/ClientLib/CRT.h" #include "tests_tools/assert.h" namespace { namespace crt = concretelang::clientlib::crt; typedef std::vector CRTModuli; // Define a fixture for instantiate test with client parameters class CRTTest : public ::testing::TestWithParam {}; TEST_P(CRTTest, crt_iCrt) { auto moduli = GetParam(); // Max representable value from moduli uint64_t maxValue = 1; for (auto modulus : moduli) maxValue *= modulus; maxValue = maxValue - 1; std::vector valuesToTest{0, maxValue / 2, maxValue}; for (auto a : valuesToTest) { auto remainders = crt::crt(moduli, a); auto b = crt::iCrt(moduli, remainders); ASSERT_EQ(a, b); } } std::vector generateAllParameters() { return { // This is our default moduli for the 16 bits {7, 8, 9, 11, 13}, }; } INSTANTIATE_TEST_SUITE_P(CRTSuite, CRTTest, ::testing::ValuesIn(generateAllParameters()), [](const testing::TestParamInfo info) { auto moduli = info.param; std::string desc("mod"); if (!moduli.empty()) { for (auto b : moduli) { desc = desc + "_" + std::to_string(b); } } return desc; }); } // namespace