Repository navigation
[27/N] Add unit tests for Stack, Queue, and Deque algorithms (Array and LL variants) - #118
Open
karkir0003 wants to merge 27 commits into
Conversation
…de, and AnimatedCircularlyLinkedListNode
karkir0003
force-pushed
the
karthik/kar-34-add-unit-tests-for-stack-queue-and-deque-algorithms-array-and-ll
branch
from
October 3, 2026 16:28
aac069d to
1f4f64a
Compare
This was referenced Oct 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stack
Addresses #93
Context
Adds comprehensive unit test coverage for the stack, queue, and deque algorithm visualizers across both array-backed and linked-list-backed implementations:
•
StackArray.js: Array-backed stack with dynamic doubling resize.•
StackLL.js: Singly linked-list backed stack with Head pointer.•
QueueArray.js: Circular array-backed queue with modulo index wrap-around and unrolling resize.•
QueueLL.js: Linked-list backed queue with Head and Tail pointers.•
DequeArray.js: Double-ended circular array with front/back enqueue, dequeue, and shifted resize.•
DequeLL.js: Doubly linked-list backed deque with bidirectional Head and Tail manipulation.Changes Made
• Introduced
src/algo/__tests__/StackArray.test.js:• Control registration (
pushField,pushButton,popButton,randomButton,clearButton).•
pushandpopoperations, array doubling resize when full, capacity boundaries (MAX_SIZE), shaking invalid inputs.•
randomCallback,clearCallback,reset, and URL parameter deserialization (setURLData).• Introduced
src/algo/__tests__/StackLL.test.js:• Linked list node instantiation, head pointer updates, and boundary shaking.
• Push to empty vs non-empty stack, pop multi-node vs single-node nullifying Head.
•
randomCallback,clearAll,reset, andsetURLDataorder verification.• Introduced
src/algo/__tests__/QueueArray.test.js:• Circular array modulo indexing for
enqueue((front + size) % arraySize) anddequeue.• Unrolling circular elements on dynamic doubling resize.
• Input validation, capacity limits, random generation, and parameter loading.
• Introduced
src/algo/__tests__/QueueLL.test.js:• Queue node linking with Head and Tail pointer maintenance.
• Dequeue operations handling single-element nullification and multi-element head advancement.
• Reset, clear, random routines, and URL data.
• Introduced
src/algo/__tests__/DequeArray.test.js:• Double-ended operations:
addFirst,addLast,removeFirst,removeLastwith circular modulo indexing.• Specialized resize logic handling element shifting when expanding from front vs back.
• Edge cases (underflow shaking, empty inputs, capacity overflow), clear, and URL loading.
• Introduced
src/algo/__tests__/DequeLL.test.js:• Doubly linked list node creation, bidirectional pointer wiring (
connectPrev/connectNext).• Add/remove at front, back, and arbitrary index.
• Boundary handling (single-element deletion, empty deque checks), reset, clear, and URL parsing.
Test Plan
• Ran
npm test -- --watchAll=false(all 6 new test suites pass, 86 unit tests passing).• Ran
npm run lintandnpm run prettier(0 errors, 0 warnings).