1 #include "test/jemalloc_test.h"
2 
3 #include "jemalloc/internal/div.h"
4 
TEST_BEGIN(test_div_exhaustive)5 TEST_BEGIN(test_div_exhaustive) {
6 	for (size_t divisor = 2; divisor < 1000 * 1000; ++divisor) {
7 		div_info_t div_info;
8 		div_init(&div_info, divisor);
9 		size_t max = 1000 * divisor;
10 		if (max < 1000 * 1000) {
11 			max = 1000 * 1000;
12 		}
13 		for (size_t dividend = 0; dividend < 1000 * divisor;
14 		    dividend += divisor) {
15 			size_t quotient = div_compute(
16 			    &div_info, dividend);
17 			assert_zu_eq(dividend, quotient * divisor,
18 			    "With divisor = %zu, dividend = %zu, "
19 			    "got quotient %zu", divisor, dividend, quotient);
20 		}
21 	}
22 }
23 TEST_END
24 
25 int
main(void)26 main(void) {
27 	return test_no_reentrancy(
28 	    test_div_exhaustive);
29 }
30