Procházet zdrojové kódy

avl_tree: bug fixes + tests + nit

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> před 10 roky
rodič
revize
227690f3b0
1 změnil soubory, kde provedl 31 přidání a 2 odebrání
  1. +31
    -2
      src/t/algorithm/avl_tree.cpp

+ 31
- 2
src/t/algorithm/avl_tree.cpp Zobrazit soubor

@@ -12,8 +12,6 @@

#include <lol/engine-internal.h>

#include <lol/algorithm/avl_tree.h>

#include <lolunit.h>

namespace lol
@@ -95,6 +93,37 @@ lolunit_declare_fixture(AvlTreeTest)
lolunit_assert_equal(tree.erase(20), true);
lolunit_assert_equal(tree.insert(20, 1), true);
}

lolunit_declare_test(AvlTreeExistence)
{
test_tree tree;

lolunit_assert_equal(tree.insert(10, 1), true);
lolunit_assert_equal(tree.get_root_balance(), 0);

lolunit_assert_equal(tree.insert(20, 1), true);
lolunit_assert_equal(tree.get_root_balance(), 1);

lolunit_assert_equal(tree.erase(10), true);
lolunit_assert_equal(tree.exists(20), true);
lolunit_assert_equal(tree.exists(10), false);

lolunit_assert_equal(tree.insert(10, 1), true);
lolunit_assert_equal(tree.get_root_balance(), -1);

lolunit_assert_equal(tree.insert(30, 1), true);
lolunit_assert_equal(tree.get_root_balance(), 0);

lolunit_assert_equal(tree.insert(40, 1), true);
lolunit_assert_equal(tree.get_root_balance(), 1);

lolunit_assert_equal(tree.insert(50, 1), true);
lolunit_assert_equal(tree.get_root_balance(), 1);

lolunit_assert_equal(tree.erase(30), true);
lolunit_assert_equal(tree.exists(40), true);
lolunit_assert_equal(tree.exists(50), true);
}
};

}

Načítá se…
Zrušit
Uložit