// test the choose sub block size function #include #include "test.h" #include #include #include #include "sub_block.h" int verbose; static void test_sub_block_size(int total_size) { if (verbose) printf("%s:%d %d\n", __FUNCTION__, __LINE__, total_size); int r; int sub_block_size, n_sub_blocks; r = choose_sub_block_size(total_size, 0, &sub_block_size, &n_sub_blocks); assert(r == EINVAL); for (int i = 1; i < max_sub_blocks; i++) { r = choose_sub_block_size(total_size, i, &sub_block_size, &n_sub_blocks); assert(r == 0); assert(0 <= n_sub_blocks && n_sub_blocks <= i); assert(total_size <= n_sub_blocks * sub_block_size); } } int test_main (int argc, const char *argv[]) { int i; for (i=1; i