MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test

Function test

code/other/nth_permutation.test.cpp:11–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11void test() {
12 assert_equal(string("0,1,2"), toString(nth_permutation(3, 0)));
13 assert_equal(string("0,2,1"), toString(nth_permutation(3, 1)));
14 assert_equal(string("1,0,2"), toString(nth_permutation(3, 2)));
15 assert_equal(string("1,2,0"), toString(nth_permutation(3, 3)));
16 assert_equal(string("2,0,1"), toString(nth_permutation(3, 4)));
17 assert_equal(string("2,1,0"), toString(nth_permutation(3, 5)));
18
19 vector<int> perm(9);
20 for (int i = 0; i < 9; i++) perm[i] = i;
21 for (int i = 0; i < 10000; i++) {
22 assert_equal(toString(perm), toString(nth_permutation(9, i)));
23 next_permutation(perm.begin(), perm.end());
24 }
25}
26// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 3

toStringFunction · 0.85
nth_permutationFunction · 0.85
assert_equalFunction · 0.50

Tested by

no test coverage detected