r/computerscience • • 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

7 comments sorted by

View all comments

Show parent comment

1

u/dJPTeach Feb 05 '26

Write a method to traverse and print the entire data structure. If you are using am array to store the data, have a function that prints the entire array. Same if you are using nodes. That way you can visually verify what is stored.