-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen-array-with-opt.cpp
More file actions
40 lines (35 loc) · 1.29 KB
/
gen-array-with-opt.cpp
File metadata and controls
40 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* gen-array-with-opt -[test-count <num>]
* -[sum-n <num>]
* [-min-n <num>]
* 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. Default: 1.
* -sum-n: specify the sum of array lengths over all test cases. Default : 10^5.
* -min-n: specify the minimum array length for all test cases. Default: 1.
*/
#include "testlib.h"
#include <vector>
using namespace std;
int main(int argc, char** argv) {
registerGen(argc, argv, 1);
int test_count = opt<int>("test-count", 1);
int sum_n = opt<int>("sum-n", 100000);
int min_n = opt<int>("min-n", 1);
int min_value = opt<int>("min-value", 1);
int max_value = opt<int>("max-value", 1000 * 1000 * 1000);
int value_bias = opt<int>("value-bias", 0);
vector<int> 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<int> arr(n);
for (int i = 0; i < n; ++i) {
arr[i] = rnd.wnext(min_value, max_value, value_bias);
}
println(n);
println(arr);
}
}