@@ -56,7 +56,7 @@ TEST(InternalMathTest, Barrett) {
56
56
ASSERT_EQ (0 , bt.mul (0 , 0 ));
57
57
}
58
58
59
- TEST (InternalMathTest, BarrettBorder ) {
59
+ TEST (InternalMathTest, BarrettIntBorder ) {
60
60
const int mod_upper = std::numeric_limits<int >::max ();
61
61
for (unsigned int mod = mod_upper; mod >= mod_upper - 20 ; mod--) {
62
62
internal::barrett bt (mod);
@@ -78,6 +78,28 @@ TEST(InternalMathTest, BarrettBorder) {
78
78
}
79
79
}
80
80
81
+ TEST (InternalMathTest, BarrettUintBorder) {
82
+ const unsigned int mod_upper = std::numeric_limits<unsigned int >::max ();
83
+ for (unsigned int mod = mod_upper; mod >= mod_upper - 20 ; mod--) {
84
+ internal::barrett bt (mod);
85
+ std::vector<unsigned int > v;
86
+ for (int i = 0 ; i < 10 ; i++) {
87
+ v.push_back (i);
88
+ v.push_back (mod - i);
89
+ v.push_back (mod / 2 + i);
90
+ v.push_back (mod / 2 - i);
91
+ }
92
+ for (auto a : v) {
93
+ ull a2 = a;
94
+ ASSERT_EQ (((a2 * a2) % mod * a2) % mod, bt.mul (a, bt.mul (a, a)));
95
+ for (auto b : v) {
96
+ ull b2 = b;
97
+ ASSERT_EQ ((a2 * b2) % mod, bt.mul (a, b));
98
+ }
99
+ }
100
+ }
101
+ }
102
+
81
103
TEST (InternalMathTest, IsPrime) {
82
104
ASSERT_FALSE (internal::is_prime<121 >);
83
105
ASSERT_FALSE (internal::is_prime<11 * 13 >);
0 commit comments