Merge binary tree debug test cases with unit tests
This commit is contained in:
@@ -104,7 +104,7 @@ bool TestDeletion()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugDeletionCase(
|
bool TestDeletionCase(
|
||||||
std::vector<unsigned> const toInsert,
|
std::vector<unsigned> const toInsert,
|
||||||
std::vector<unsigned> const toDelete,
|
std::vector<unsigned> const toDelete,
|
||||||
std::vector<unsigned> const result)
|
std::vector<unsigned> const result)
|
||||||
@@ -142,28 +142,28 @@ bool DebugDeletionCase(
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugDeletion()
|
bool TestDeletionCases()
|
||||||
{
|
{
|
||||||
std::puts("Testing deleting root with single child right.");
|
std::puts("Testing deleting root with single child right.");
|
||||||
DebugDeletionCase(
|
TestDeletionCase(
|
||||||
std::vector<unsigned> { 10, 12, 11, 13},
|
std::vector<unsigned> { 10, 12, 11, 13},
|
||||||
std::vector<unsigned> { 10 },
|
std::vector<unsigned> { 10 },
|
||||||
std::vector<unsigned> { 12, 11, 13 });
|
std::vector<unsigned> { 12, 11, 13 });
|
||||||
|
|
||||||
std::puts("Testing deleting root with single child left.");
|
std::puts("Testing deleting root with single child left.");
|
||||||
DebugDeletionCase(
|
TestDeletionCase(
|
||||||
std::vector<unsigned> { 15, 12, 11, 13},
|
std::vector<unsigned> { 15, 12, 11, 13},
|
||||||
std::vector<unsigned> { 15 },
|
std::vector<unsigned> { 15 },
|
||||||
std::vector<unsigned> { 12, 11, 13 });
|
std::vector<unsigned> { 12, 11, 13 });
|
||||||
|
|
||||||
std::puts("Testing deleting root with 2 children but no child right left.");
|
std::puts("Testing deleting root with 2 children but no child right left.");
|
||||||
DebugDeletionCase(
|
TestDeletionCase(
|
||||||
std::vector<unsigned> { 15, 10, 20, 22, 25, 18, 5},
|
std::vector<unsigned> { 15, 10, 20, 22, 25, 18, 5},
|
||||||
std::vector<unsigned> { 20 },
|
std::vector<unsigned> { 20 },
|
||||||
std::vector<unsigned> { 15, 10, 22, 25, 18, 5 });
|
std::vector<unsigned> { 15, 10, 22, 25, 18, 5 });
|
||||||
|
|
||||||
std::puts("Testing deleting root with 2 children.");
|
std::puts("Testing deleting root with 2 children.");
|
||||||
DebugDeletionCase(
|
TestDeletionCase(
|
||||||
std::vector<unsigned> { 50, 40, 60, 75, 55, 45, 42, 58 },
|
std::vector<unsigned> { 50, 40, 60, 75, 55, 45, 42, 58 },
|
||||||
std::vector<unsigned> { 50 },
|
std::vector<unsigned> { 50 },
|
||||||
std::vector<unsigned> { 40, 60, 75, 55, 45, 42, 58 });
|
std::vector<unsigned> { 40, 60, 75, 55, 45, 42, 58 });
|
||||||
@@ -171,18 +171,12 @@ bool DebugDeletion()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debug()
|
|
||||||
{
|
|
||||||
std::puts("\n*** DEBUG ***");
|
|
||||||
Test::Execute(DebugDeletion, "Deletion debug test");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Test::Execute(TestInsert, "Insertion and find test");
|
Test::Execute(TestInsert, "Insertion and find test");
|
||||||
Test::Execute(TestInsertNoDuplicates, "Insertion without duplicates test");
|
Test::Execute(TestInsertNoDuplicates, "Insertion without duplicates test");
|
||||||
Test::Execute(TestDeletion, "Insertion and deletion test");
|
Test::Execute(TestDeletion, "Insertion and deletion test");
|
||||||
Debug();
|
Test::Execute(TestDeletionCases, "Deletion cases test");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user