Added a test that exposes a problem in BObjectList/PointerList. If a list contains 17 items or greater, and you attempt to sort it with a sort function that always returns 1 regardless of the items being compared, it will crash 100% of the time. Looking into why next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28873 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
51505cb08a
commit
4c1a09d0cf
35
src/tests/kits/support/pointerlist/PointerListSortTest.cpp
Normal file
35
src/tests/kits/support/pointerlist/PointerListSortTest.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <ObjectList.h>
|
||||
#include <String.h>
|
||||
|
||||
static int SortItemTestPositive(const BString *item1, const BString *item2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int SortItemTestNegative(const BString *item1, const BString *item2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int SortItemTestEqual(const BString *item1, const BString *item2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
BObjectList<BString> list;
|
||||
for (int i = 0; i < 20; i++) {
|
||||
list.AddItem(new BString("test"));
|
||||
printf("List contains %d items, attempting sorts\n", i);
|
||||
printf("Attempting positive test\n");
|
||||
list.SortItems(SortItemTestPositive);
|
||||
printf("Positive test completed, attempting negative test\n");
|
||||
list.SortItems(SortItemTestNegative);
|
||||
printf("Positive test completed, attempting equal test\n");
|
||||
list.SortItems(SortItemTestEqual);
|
||||
}
|
||||
printf("All tests passed!\n");
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user