[Haiku-commits] r28873 - haiku/trunk/src/tests/kits/support/pointerlist
anevilyak at BerliOS
anevilyak at mail.berlios.de
Sun Jan 11 05:43:54 CET 2009
Author: anevilyak
Date: 2009-01-11 05:43:53 +0100 (Sun, 11 Jan 2009)
New Revision: 28873
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=28873&view=rev
Added:
haiku/trunk/src/tests/kits/support/pointerlist/PointerListSortTest.cpp
Log:
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.
Added: haiku/trunk/src/tests/kits/support/pointerlist/PointerListSortTest.cpp
===================================================================
--- haiku/trunk/src/tests/kits/support/pointerlist/PointerListSortTest.cpp 2009-01-11 03:08:56 UTC (rev 28872)
+++ haiku/trunk/src/tests/kits/support/pointerlist/PointerListSortTest.cpp 2009-01-11 04:43:53 UTC (rev 28873)
@@ -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;
+}
More information about the Haiku-commits
mailing list