| 9 | } |
| 10 | |
| 11 | void 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: |
nothing calls this directly
no test coverage detected