// Error a propósito: tras la primera reparación ya no se repara más arriba.
// Al insertar nunca hace falta otra, así que el error solo aparece al borrar.
#include <iostream>
#include <random>

#include "../fibonacci_tree.h"
#include "broken_avl.h"

int main() {
    std::cout << std::unitbuf;
    BrokenAvl<Bug::stop_after_first_repair> random_tree;
    std::mt19937 random(2026);
    std::uniform_int_distribution<int> key_of(0, 100000);
    for (int i = 0; i < 5000; i++) {
        random_tree.insert(key_of(random));
        random_tree.check_invariants();
    }
    std::cout << "5000 inserciones al azar: todas pasan check_invariants\n";
    BrokenAvl<Bug::stop_after_first_repair> tree;
    for (int key : fibonacci_keys(4)) {
        tree.insert(key);
    }
    tree.check_invariants();
    std::cout << "antes de borrar 12: " << tree.shape() << "\n";
    tree.erase(12);
    std::cout << "despues de borrar 12: " << tree.shape() << "\n";
    tree.check_invariants();
    std::cout << "check_invariants no vio nada\n";
    return 0;
}
