TEST_F( SimplexSupportDoublyLinkedList, PushBackAddsElement ) { MockStruct* m = new MockStruct(); DoublyLinkedList list; list.PushBack( m ); ASSERT_EQ ( (MockStruct*)list.Last()->Value, m ); delete(m); }
TEST_F( SimplexSupportDoublyLinkedList, PopFrontUpdatesLastWhenListIsEmptied ) { MockStruct* m = new MockStruct(); DoublyLinkedList list; list.PushFront( m ); list.PopFront(); ASSERT_EQ ( list.Last(), nullptr ); delete(m); }
TEST_F( SimplexSupportDoublyLinkedList, PushFrontSetsLastElementIfNoElementPresent ) { MockStruct* m = new MockStruct(); DoublyLinkedList list; list.PushFront( m ); ASSERT_EQ ( (MockStruct*)list.Last()->Value, m ); delete(m); }
TEST_F( SimplexSupportDoublyLinkedList, LastReturnsLastAddedElement ) { MockStruct* m1 = new MockStruct(); MockStruct* m2 = new MockStruct(); MockStruct* m3 = new MockStruct(); DoublyLinkedList list; list.PushBack(m1); ASSERT_EQ(list.Last()->Value, (MockStruct*)m1); list.PushBack(m2); ASSERT_EQ(list.Last()->Value, (MockStruct*)m2); list.PushBack(m3); ASSERT_EQ(list.Last()->Value, (MockStruct*)m3); delete(m1); delete(m2); delete(m3); }
// // Last // TEST_F( SimplexSupportDoublyLinkedList, LastPreservesConnectionToPreviousLast ) { MockStruct* m1 = new MockStruct(); MockStruct* m2 = new MockStruct(); DoublyLinkedList list; list.PushBack(m1); list.PushBack(m2); ASSERT_EQ(list.Last()->Previous->Value, (MockStruct*)m1); delete(m1); delete(m2); }
TEST_F( SimplexSupportDoublyLinkedList, PushBackSetsPreviousAndNextCorrectly ) { MockStruct* m1 = new MockStruct(); MockStruct* m2 = new MockStruct(); DoublyLinkedList list; list.PushBack( m1 ); list.PushBack( m2 ); ASSERT_EQ( list.Last()->Previous->Value, m1); ASSERT_EQ( list.First()->Next->Value, m2); delete(m1); delete(m2); }
// // RemoveAt // TEST_F( SimplexSupportDoublyLinkedList, RemoveAtLeavesAConsistentList ) { MockStruct* m1 = new MockStruct(); MockStruct* m2 = new MockStruct(); MockStruct* m3 = new MockStruct(); DoublyLinkedList list; list.PushBack(m1); list.PushBack(m2); list.PushBack(m3); list.RemoveAt(1); ASSERT_EQ((MockStruct*)list.First()->Next->Value, m3); ASSERT_EQ((MockStruct*)list.Last()->Previous->Value, m1); delete(m1); delete(m2); delete(m3); }