I have written all kinds of testing and example inputs/outputs and I have separated them, however, the question then becomes really long as you can see and may put people off from answering.
Here's how you can reduce your code to a minimal reproducible example:
- Go through your testing code to find the first printed output that is incorrect compared to your expected output.
- Delete all of the test code after that, since it can't affect the printed output.
- Delete the prints which happen before that, because their outputs are correct and therefore unnecessary to reproduce the issue. If there is any other code in the test which isn't necessary to set up the failing test output, delete this too.
- You now have a single test which fails. Delete all of the code that isn't used by that one test. For example, if your test only needs the
add
method then you can delete the remove
and count
methods, and the test will still reproduce the issue properly.
- Rewrite your expected output to be just the result for that one test.
- Also write the actual output that you are getting from that one test, and explain in text what the difference is to your expected output (unless it's really blatant).
Yes, this is a lot of work, but as the person writing the code and asking the question, this work is your responsibility. If you don't do this work yourself, then effectively you are asking other people to do it for you; the more work it takes for someone to answer your question, the less likely anyone will bother to answer it. On the other hand, doing that work yourself will improve your debugging skills and make you more capable as a programmer, and you might even solve the problem yourself in the process.
_searchNode
,count
,remove
andmax
is wrong. You surely can focus on one thing, like for example how to makemax
work correctly. You don't needcount
,_searchNode
, norremove
for that functionality. Simplify the test case to just test that feature in a way that it illustratesmax
is giving the wrong output. Remove any code that is not used.remove
function has little to nothing in it that relates to your data structure and looks like copied from a linked list context. I find it really disappointing, as even the simplest code review shows the complete disconnect between that function and your data structure. It shows no effort of basic testing, debugging as even the attribute/property names do not correspond to anything in your data structure.