| 1 | #include "../code/data-structures/avl_tree.cpp" |
| 2 | |
| 3 | void test() { |
| 4 | misof_tree t1; |
| 5 | avl_tree<int> t2; |
| 6 | |
| 7 | for (int i = 0; i < 1000000; i++) { |
| 8 | int op = rng() % 3; |
| 9 | |
| 10 | if (op == 0) { |
| 11 | int x = rng() % (1 << BITS); |
| 12 | |
| 13 | // printf("insert %d\n", x); |
| 14 | |
| 15 | if (t2.find(x) == NULL) |
| 16 | { |
| 17 | t1.insert(x); |
| 18 | t2.insert(x); |
| 19 | } |
| 20 | else i--; |
| 21 | |
| 22 | } else if (op == 1 && size(t2) > 0) { |
| 23 | int x = t2.nth(rng() % size(t2))->item; |
| 24 | |
| 25 | // printf("erase %d\n", x); |
| 26 | |
| 27 | t1.erase(x); |
| 28 | t2.erase(x); |
| 29 | } else if (op == 2 && size(t2) > 0) { |
| 30 | int n = rng() % size(t2); |
| 31 | |
| 32 | // printf("nth %d: %d, %d\n", n, t2.nth(n)->item, t1.nth(n)); |
| 33 | |
| 34 | assert_equal(t2.nth(n)->item, t1.nth(n), true); |
| 35 | } else i--; |
| 36 | } |
| 37 | } |
| 38 | // vim: cc=60 ts=2 sts=2 sw=2: |
nothing calls this directly
no test coverage detected