@@ -137,18 +137,25 @@ class NCRModuloP {
137
137
* @returns void
138
138
*/
139
139
static void tests () {
140
- // (52323 C 26161) % (1e9 + 7) = 224944353
141
- assert (
142
- math::ncr_modulo_p::NCRModuloP (60000 , 1000000007 ).ncr (52323 , 26161 ) ==
143
- 224944353 );
144
- // 6 C 2 = 30, 30%5 = 0
145
- assert (math::ncr_modulo_p::NCRModuloP (20 , 5 ).ncr (6 , 2 ) == 0 );
146
- // 7C3 = 35, 35 % 29 = 8
147
- assert (math::ncr_modulo_p::NCRModuloP (100 , 29 ).ncr (7 , 3 ) == 6 );
148
- }
140
+ struct TestCase {
141
+ const uint64_t size;
142
+ const uint64_t p;
143
+ const uint64_t n;
144
+ const uint64_t r;
145
+ const int64_t expected;
149
146
150
- void other_tests () {
151
- assert (math::ncr_modulo_p::NCRModuloP (1000 , 13 ).ncr (10 , 3 ) == 120 % 13 );
147
+ TestCase (const uint64_t size, const uint64_t p, const uint64_t n,
148
+ const uint64_t r, const int64_t expected)
149
+ : size(size), p(p), n(n), r(r), expected(expected) {}
150
+ };
151
+ const std::vector<TestCase> test_cases = {
152
+ TestCase (60000 , 1000000007 , 52323 , 26161 , 224944353 ),
153
+ TestCase (20 , 5 , 6 , 2 , 30 % 5 ), TestCase (100 , 29 , 7 , 3 , 35 % 29 ),
154
+ TestCase (1000 , 13 , 10 , 3 , 120 % 13 )};
155
+ for (const auto & tc : test_cases) {
156
+ assert (math::ncr_modulo_p::NCRModuloP (tc.size , tc.p ).ncr (tc.n , tc.r ) ==
157
+ tc.expected );
158
+ }
152
159
}
153
160
154
161
/* *
@@ -166,7 +173,6 @@ int main() {
166
173
std::cout << 6 << " C" << i << " = " << ncrObj.ncr (6 , i) << " \n " ;
167
174
}
168
175
tests (); // execute the tests
169
- other_tests ();
170
176
std::cout << " Assertions passed\n " ;
171
177
return 0 ;
172
178
}
0 commit comments