Linked list: optimized insertBefore(), elaborated docs

This commit is contained in:
Pavel Kirienko
2015-01-18 01:20:56 +03:00
parent 5209806304
commit 8a5d001e29
2 changed files with 29 additions and 4 deletions
+16
View File
@@ -104,11 +104,27 @@ TEST(LinkedList, Sorting)
uavcan::LinkedListRoot<ListItem> root;
ListItem items[] = {0, 1, 2, 3, 4, 5};
EXPECT_EQ(0, root.getLength());
items[2].insort(root);
EXPECT_EQ(1, root.getLength());
items[2].insort(root); // Making sure the duplicate will be removed
EXPECT_EQ(1, root.getLength());
items[3].insort(root);
items[0].insort(root);
items[4].insort(root);
EXPECT_EQ(4, root.getLength());
items[1].insort(root);
EXPECT_EQ(5, root.getLength());
items[1].insort(root); // Another duplicate
EXPECT_EQ(5, root.getLength());
items[5].insort(root);
EXPECT_EQ(6, root.getLength());