Fixed the sigsegv bug in binary tree
This commit is contained in:
parent
88e4385c5f
commit
7c74b68d75
2 changed files with 45 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue