/** * gen-array-with-opt -test-count * -sum-n * [-min-n ] * [-min-value ] [-max-value ] * [-value-bias ] * * Generate a test with `test-count` test cases, each test case is an * array. The sum of lengths of all arrays will equal `sum-n`. * * Arguments: * -test-count: specify the number of test cases. Required. * -sum-n: specify the sum of array lengths over all test cases. Required. * -min-n: specify the minimum array length for all test cases. Default: 1. * -min-value: specify the minimum value for the array element. Default: 1. * -max-value: specify the maximum value for the array element. Default: 10^9. * -value-bias: specify the bias for generating the value. The bigger the * _positive_ value-bias, the closer the element to max-value. The smaller the * _negative_ value-bias, the closer the element to min-value. See rnd.wnext() * function. Default: 0 (no bias). */ #include "testlib.h" #include using namespace std; int main(int argc, char** argv) { registerGen(argc, argv, 1); int test_count = opt("test-count"); int sum_n = opt("sum-n"); int min_n = opt("min-n", 1); int min_value = opt("min-value", 1); int max_value = opt("max-value", 1000 * 1000 * 1000); int value_bias = opt("value-bias", 0); vector n_list = rnd.partition(test_count, sum_n, min_n); println(test_count); for (int test_case = 0; test_case < test_count; ++test_case) { int n = n_list[test_case]; vector arr(n); for (int i = 0; i < n; ++i) { arr[i] = rnd.wnext(min_value, max_value, value_bias); } println(n); println(arr); } }