I am experiencing trouble trying to create a unit test for all the functions in my Linked List. Mainly I'm having trouble with my insert function that builds but just does not insert, and my First function which just returns the data in the first slot of my Linked List.
I am getting the following error for my code: newNodeCatch = myList.First();
Error C2440 'return': cannot convert from 'int' to 'ListNode<T> *' UnitTest
PS. My teacher helped to create the Linked List with me so I assume it is all correct code but I find it quite difficult to follow.
I am getting the following error for my code: newNodeCatch = myList.First();
Error C2440 'return': cannot convert from 'int' to 'ListNode<T> *' UnitTest
Should First() and Last() return a value or a pointer to a node? If you want them to return a value you need to change the return type of those two functions from ListNode<T>* to T, and change the code in TestLinkedList() so that you assign the return value of myList.First() to an int variable.
My teacher helped to create the Linked List with me so I assume it is all correct code
Well there's your problem :).
Insert() doesn't seem to do anything.
After putting it all in one file (for my own convenience) and fixing the compiler errors, it seems to work. Note that I had to #define _ASSERT because my compiler doesn't support it.
Yeah, I suppose that still matches the requirements. Guess the teachers can't mark me down for that but I do have the feeling I'm supposed to use the Iter class...
Of course they don't change the code, they only show that's sth. wrong. They are universal, _ASSERT is VS but assert is standard C++.
Look at his code
First I create an empty list and list.Count() == 0 which is correct.
Then I add one value and the count is still 0, if this is not wrong what is it then ????