-
-
Notifications
You must be signed in to change notification settings - Fork 409
feat: stack with linked list #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: stack with linked list #110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I wonder whether you could reasonably deduplicate the tests by applying the singly linked list tests to the doubly linked list as well?
Do you mean I should merge them in one single file and execute the tests for both lists there? |
If the singly linked list has the same interface as the doubly linked one (where of course some operations will be linear rather than constant time): Yes, you can use one file and a test parameterized in terms of the constructor to use. You might as well use three files though: One for the parameterized tests and two (trivial) files which just import the parameterized test and execute it for a given implementation. For an example of this, see the queue tests consolidated in 124890c: Both the However, if you want to support only a subset of the doubly linked list operations, you should still keep the "doubly linked list"-only tests for the doubly linked list; the common tests should however be deduplicated using the parameterization described above. |
Alright, the linked lists now have an interface with their shared methods and a combined test case. The additional reverse() function of the doubly linked list has also an own test case it its test file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing.
Odd. The tests are failing due to something that hasn't even been touched. Perhaps you need to rebase? |
The |
Alright, I check this out |
Well yeah, seems logical that after the first test, a stack overflow occurred, when pushing three new elements before each test run. |
This is an implementation of a singly linked list and a stack based on a singly linked list.
Additional note: I had some trouble with the tests of the stack implementation. All tests passed when running them individually, but however they failed when running them "all at once" (testing the whole file). The issues that came seemed weird, as for example there was a "Stack overflow" error when popping the element from the stack. I think and hope this is a local issue with my machine. If it is one with the tests I wrote, feel free to correct me.
And, just to clarify it here, I adjusted the test cases of the linked list from the doubly linked list (and verified their functionality), because the operations are basically the same and I think the test cases fulfilled everything. So credits to @zFl4wless for writing these tests.