Skip to content

[33/N] Add unit tests for LSDRadix, RadixSort, BogoSort, DropSort, FredSort, MiracleSort, and SleepSort algorithms - #124

Open
karkir0003 wants to merge 33 commits into
csvistool:masterfrom
karkir0003:karthik/kar-40-add-unit-tests-for-non-comparison-and-esoteric-sorts
Open

karkir0003 wants to merge 33 commits into
csvistool:masterfrom
karkir0003:karthik/kar-40-add-unit-tests-for-non-comparison-and-esoteric-sorts

Conversation

@karkir0003

@karkir0003 karkir0003 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack

  1. ⬅️ [1/N] Update CI to run frontend unit tests #91 (Add test infrastructure and Jest setup)
  2. ⬅️ [2/N] Configure React Testing Library and Setup Tests #92 (Add unit tests for Header, Footer, and Blob components)
  3. ⬅️ [3/N] Add unit tests for SideButton component #94 (Add unit tests for HomeScreen components (SideButton, SearchFilter))
  4. ⬅️ [4/N] Add unit tests for SearchFilter component #95 (Add unit tests for AlgoScreen components (AlgoSection, Pseudocode, ModalSidebarSectionTab))
  5. ⬅️ [6/N] Add unit tests for Blob mascot component #97 (Add unit tests for modals (BigOModal, InfoModals))
  6. ⬅️ [5/N] Add unit tests for Header and Footer components #96 (Add unit tests for AlgorithmNotFound404 component)
  7. ⬅️ [7/N] Add unit tests for AboutScreen screen #98 (Add unit tests for HomeScreen page)
  8. ⬅️ [8/N] Add integration tests for HomeScreen screen #99 (Add unit tests for AboutScreen page)
  9. ⬅️ [9/N] Add unit tests for AlgorithmNotFound404 component #100 (Add unit tests for AlgoScreen page)
  10. ⬅️ [10/N] Add integration tests for AlgoScreen screen #101 (Add unit tests for App root component and routes)
  11. ⬅️ [11/N] Add unit tests for ModalSidebarSectionTab component #102 (Add test coverage workflow for CI)
  12. ⬅️ [12/N] Add unit tests for BigOModal component #103 (Add unit tests for CustomEvents animation utility)
  13. ⬅️ [13/N] Add unit tests for Pseudocode component #104 (Add unit tests for UndoFunctions animation utility)
  14. ⬅️ [14/N] Add unit and integration tests for AlgoSection component #105 (Add unit tests for AnimatedCircle animation primitive)
  15. ⬅️ [15/N] Add unit and integration tests for root App component #106 (Add unit tests for AnimatedHighlightCircle)
  16. ⬅️ [16/N] Add unit tests for animation events and undo functions #107 (Add unit tests for SingleAnimation)
  17. ⬅️ [17/N] Add unit tests for AnimatedObject, AnimatedCircle, and AnimatedHighlightCircle #108 (Add unit tests for AnimatedObject base class)
  18. ⬅️ [18/N] Add unit tests for AnimatedRectangle, AnimatedLabel, and AnimatedLine #109 (Add unit tests for AnimatedRectangle, AnimatedLabel, and AnimatedLine)
  19. ⬅️ [19/N] Add unit tests for AnimatedLinkedListNode, AnimatedDoublyLinkedListNode, and AnimatedCircularlyLinkedListNode #110 (Add unit tests for AnimatedLinkedListNode, AnimatedDoublyLinkedListNode, and AnimatedCircularlyLinkedListNode)
  20. ⬅️ [20/N] Add unit tests for AnimatedBTreeNode and AnimatedSkipListNode #111 (Add unit tests for AnimatedBTreeNode and AnimatedSkipListNode)
  21. ⬅️ [21/N] Add unit tests for ObjectManager #112 (Add unit tests for ObjectManager)
  22. ⬅️ [22/N] Add unit tests for AnimationMain #113 (Add unit tests for AnimationMain)
  23. ⬅️ [23/N] Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues) #114 (Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues))
  24. ⬅️ [24/N] Add unit tests for base Algorithm class and control bar helpers #115 (Add unit tests for base Algorithm class and control bar helpers)
  25. ⬅️ [25/N] Add unit tests for ArrayList algorithm #116 (Add unit tests for ArrayList algorithm)
  26. ⬅️ [26/N] Add unit tests for LinkedList, DoublyLinkedList, and CircularlyLinkedList algorithms #117 (Add unit tests for LinkedList, DoublyLinkedList, and CircularlyLinkedList algorithms)
  27. ⬅️ [27/N] Add unit tests for Stack, Queue, and Deque algorithms (Array and LL variants) #118 (Add unit tests for Stack, Queue, and Deque algorithms (Array and LL variants))
  28. ⬅️ [28/N] Add unit tests for BST, AVL, Heap, and SplayTree algorithms #119 (Add unit tests for BST, AVL, Heap, and SplayTree algorithms)
  29. ⬅️ [29/N] Add unit tests for BTree, TreeMap, SkipList, and DisjointSet algorithms #120 (Add unit tests for BTree, TreeMap, SkipList, and DisjointSet algorithms)
  30. ⬅️ [30/N] Add unit tests for Hash, OpenHash, ClosedHash, and NonLinearProbing algorithms #121 (Add unit tests for Hash, OpenHash, ClosedHash, and NonLinearProbing algorithms)
  31. ⬅️ [31/N] Add unit tests for BruteForce, BoyerMoore, KMP, RabinKarp, and LCS pattern matching algorithms #122 (Add unit tests for BruteForce, BoyerMoore, KMP, RabinKarp, and LCS pattern matching algorithms)
  32. ⬅️ [32/N] Add unit tests for BubbleSort, CocktailSort, SelectionSort, InsertionSort, MergeSort, Quicksort, Quickselect, and HeapSort algorithms #123 (Add unit tests for BubbleSort, CocktailSort, SelectionSort, InsertionSort, MergeSort, Quicksort, Quickselect, and HeapSort algorithms)
  33. 👉 #CURRENT — Add unit tests for LSDRadix, RadixSort, BogoSort, DropSort, FredSort, MiracleSort, and SleepSort algorithms (this PR)
  34. ➡️ [34/N] Add unit tests for Graph, BFS, DFS, Dijkstras, Prims, Kruskals, Floyd, CreateGraph, and LVA algorithms #125 (Add unit tests for Graph, BFS, DFS, Dijkstras, Prims, Kruskals, Floyd, CreateGraph, and LVA algorithms)

Addresses #93

Context

Adds comprehensive unit test coverage for non-comparison and esoteric/joke sorting algorithms:

  • LSDRadix.js: Least Significant Digit (LSD) Radix Sort with 10 buckets for positive numbers, 19 buckets (-9 to +9) for negative numbers, digit extraction passes, and negative sorting toggle (toggleNegativeNumbers).
  • RadixSort.js: Classical 3-digit Radix Sort with fixed 30-element visual layout, 10 counting-sort buckets, prefix sum calculation, and swap array copying passes.
  • BogoSort.js: Random permutation shuffling sort with sorted verification pass, duplicate element distinguishing letters, and safety abort warning for arrays >= 10 elements.
  • DropSort.js: Humorously destructive sort that iterates through array comparing adjacent elements and drops (deletes) any element smaller than its predecessor, shifting subsequent elements left.
  • FredSort.js: Partitioned sorting dividing array into ceil(sqrt(n)) sub-arrays, performing insertion sort on each partition, and merging.
  • MiracleSort.js: Satirical miracle sort visualizer that displays the array in light blue and waits indefinitely for cosmic rays to sort the data.
  • SleepSort.js: Concurrency-inspired sleep sort creating timer labels above each number, counting down to zero, and placing elements into a secondary destination array in ascending order of wakeup.

Changes Made

  • Introduced src/algo/__tests__/LSDRadix.test.js:
    • Control registration, sort button, examples dropdown, clear button, and negative numbers toggle checkbox.
    • Validation for empty list, max 18 items, non-numeric values, > 6 digits, and negative numbers when disabled.
    • Positive integer bucket distribution and collection passes.
    • Negative numbers bucket toggle (19 buckets) and negative sorting execution.
    • URL parameter parsing (negative, data).
  • Introduced src/algo/__tests__/RadixSort.test.js:
    • Fixed 30-element array structure and 10-element counter array setup.
    • Multi-pass counting sort callback execution (radixSortCallback).
    • List randomization, responsive layout size adjustments (sizeChanged), and UI enable/disable.
  • Introduced src/algo/__tests__/BogoSort.test.js:
    • Already-sorted 1-pass verification, unsorted shuffling, and iteration counter.
    • Safety abort warning for list size >= 10.
    • Input validation, duplicates handling, example loading, and UI enable/disable.
  • Introduced src/algo/__tests__/DropSort.test.js:
    • Validation for empty list, size > 18, and non-numeric / > 999 values.
    • Sorted non-dropping passes and descending element dropping with array shift animations.
    • URL parameter parsing (data), presets, and UI controls.
  • Introduced src/algo/__tests__/FredSort.test.js:
    • Partitioning into sqrt(n) chunks, sub-array drawing, insertion sort passes, and merging.
    • Input validation (max 15 items), duplicates handling, presets, and URL parameter parsing.
  • Introduced src/algo/__tests__/MiracleSort.test.js:
    • Input validation, array display, miracle waiting status message, and cell highlighting.
    • Presets, random generator, URL parameter parsing, and UI enable/disable.
  • Introduced src/algo/__tests__/SleepSort.test.js:
    • Dual-array representation (source array and secondary destination array).
    • Sleep timer label creation, countdown simulation, and wakeup placement with green sorted cells.
    • Input validation (max 15 items), duplicate handling, presets, and URL parameter parsing.

Test Plan

  • Ran npm test -- --watchAll=false (all 7 new test suites pass, 66 unit tests passing; 75 suites, 831 tests passing repository-wide).
  • Ran npm run lint and npm run prettier (0 errors, 0 warnings).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant