r/computerscience • u/maxblomgren • Feb 04 '26
How to do tests on stack datastructure
How would on go on about to test all functions of the stack datastructure?
For example: how would one test if the pushing function works without assuming the inspecting one also does? It seems just to be all circular reasoning.
1
Upvotes
View all comments
Show parent comment
1
u/maxblomgren Feb 04 '26
But doesn't that assume the implementation of pop is correct? What if, let's say, pop returns the wrong value or push doesn't push a value to the top of the stack? Is it okay to make those assumptions?