Fixed the sigsegv bug in binary tree

This commit is contained in:
vegowotenks 2024-10-13 22:05:41 +02:00
parent 88e4385c5f
commit 7c74b68d75
2 changed files with 45 additions and 11 deletions

View file

@ -216,6 +216,34 @@ void testMany(void)
return;
}
void testRanges(void)
{
allocator_t allocator;
Allocator_CreateSystemAllocator(&allocator);
BinaryTree tree;
assert(EXIT_SUCCESS == BinaryTree_Create(
&tree,
(BinaryTreeComparator) doublecomparator,
(void*) 0xDEADBEEF,
sizeof(double),
&allocator)
);
for (double value = 0; value < 300; value++) {
assert(EXIT_SUCCESS == BinaryTree_Insert(&tree, &value));
}
for (double value = 150; value <= 200; value++) {
assert(EXIT_SUCCESS == BinaryTree_Remove(&tree, &value));
}
BinaryTree_Destroy(&tree);
assert(allocator.reserved == 0);
return;
}
int main()
{
testLifetime();
@ -223,5 +251,6 @@ int main()
testEqual();
testMany();
testRemoval();
testRanges();
return 0;
}