<commit_before>#include "../lib/catch.hpp"

extern "C"
{
#include "../inc/AvlTree.h"
}

// TODO: test avl tree<commit_msg>Added unit test for AvlTree.<commit_after>#include "../lib/catch.hpp"

extern "C"
{
#include "../inc/AvlTree.h"
}

int compare(const void *a, const void *b)
{
	return (int)a - (int)b;
}

TEST_CASE("avl tree contains, delete, insert, is empty", "[inc/AvlTree.h/avlContains, inc/AvlTree.h/avlDelete, inc/AvlTree.h/avlInsert, inc/AvlTree.h/avlIsEmpty]")
{
	struct AvlTree tree;

	avlReset(&tree, &compare);
	REQUIRE(avlIsEmpty(&tree));

	for (int i = 0; i < 10; i++)
		REQUIRE(avlInsert(&tree, (void*)i));

	for (int i = 0; i < 10; i++)
		REQUIRE(avlContains(&tree, (void*)i));

	REQUIRE_FALSE(avlIsEmpty(&tree));
	REQUIRE_FALSE(avlInsert(&tree, (void*)2));
	REQUIRE_FALSE(avlContains(&tree, (void*)-1));
	REQUIRE_FALSE(avlDelete(&tree, (void*)-2));

	for (int i = 0; i < 10; i++)
		REQUIRE(avlDelete(&tree, (void*)i));

	REQUIRE(avlIsEmpty(&tree));

	for (int i = 0; i > -10; i--)
		avlInsert(&tree, (void*)i);

	avlReset(&tree, NULL);
	REQUIRE(avlIsEmpty(&tree));
}
{'fraction_non_alphanumeric': 0.212707182320442, 'fraction_numerical': 0.013812154696132596, 'mean_word_length': 4.781914893617022, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1405840', 'n_tokens_mistral': 481, 'n_tokens_neox': 466, 'n_words': 93}