These are the tests I use to unit test my implementation for LinkedLists.
It uses Catch as a testing framework.
- Clone this repository
- Put your implementation of linked lists in the same directory. Call it
LinkedList.h
or rename the#include
intest.cpp
- Remember to include your implementation of
Node<T>
(e.g.Node.h
) in the same directory or insideLinkedList.h
(not best practice)
- Remember to include your implementation of
- Run
$ g++ test.cpp -o test
$ ./test
That's it!
insertAtIndex(int, T)
isEmpty(void)
[] operator
(get version)push_back(T)
push(T)
: adds value T to the beginning of the listfirst(void)
: returns the first element of the listsize(void)
: returns the length of the listmakeEmpty(void)
: empties the list (deleting everything)frontBackSplit(Node<T>** a, Node<T>** b)
: places the first half of the list in a, and the second half in b.pop(void)
: returns and removes the first element on the list
- The tests assume your linked list class is called
LinkedList
and your linked list node is calledNode
. - The tests assume you're using templates
<T>
- You're exposing your linked list head in a
public
head
attribute in your class