diff --git a/tests/unit/data-structures/graph/abstract-graph.test.ts b/tests/unit/data-structures/graph/abstract-graph.test.ts new file mode 100644 index 0000000..dc5d2c9 --- /dev/null +++ b/tests/unit/data-structures/graph/abstract-graph.test.ts @@ -0,0 +1,5 @@ +describe('AbstractGraph Operation Test', () => { + it('should xxx', function () { + expect(true).toBe(true); + }); +}); \ No newline at end of file diff --git a/tests/unit/data-structures/graph/abstract-graph.ts b/tests/unit/data-structures/graph/abstract-graph.ts deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/data-structures/graph/directed-graph.test.ts b/tests/unit/data-structures/graph/directed-graph.test.ts index 988264e..b364c8c 100644 --- a/tests/unit/data-structures/graph/directed-graph.test.ts +++ b/tests/unit/data-structures/graph/directed-graph.test.ts @@ -1,6 +1,6 @@ import {DirectedEdge, DirectedGraph, DirectedVertex, VertexId} from '../../../../src'; -describe('DirectedGraph Test1', () => { +describe('DirectedGraph Operation Test', () => { let graph: DirectedGraph; beforeEach(() => { diff --git a/tests/unit/data-structures/graph/index.ts b/tests/unit/data-structures/graph/index.ts index e568360..552cec7 100644 --- a/tests/unit/data-structures/graph/index.ts +++ b/tests/unit/data-structures/graph/index.ts @@ -1,2 +1,2 @@ export * from './directed-graph.test'; -export * from './undirected-graph'; +export * from './undirected-graph.test'; diff --git a/tests/unit/data-structures/graph/undirected-graph.test.ts b/tests/unit/data-structures/graph/undirected-graph.test.ts new file mode 100644 index 0000000..af852ea --- /dev/null +++ b/tests/unit/data-structures/graph/undirected-graph.test.ts @@ -0,0 +1,5 @@ +describe('UndirectedGraph Operation Test', () => { + it('should xxx', function () { + + }); +}); diff --git a/tests/unit/data-structures/graph/undirected-graph.ts b/tests/unit/data-structures/graph/undirected-graph.ts deleted file mode 100644 index 48f510e..0000000 --- a/tests/unit/data-structures/graph/undirected-graph.ts +++ /dev/null @@ -1,3 +0,0 @@ -describe('UndirectedGraph Test1', () => { - -}); diff --git a/tests/unit/data-structures/heap/heap.test.ts b/tests/unit/data-structures/heap/heap.test.ts index f058a6c..e0a0728 100644 --- a/tests/unit/data-structures/heap/heap.test.ts +++ b/tests/unit/data-structures/heap/heap.test.ts @@ -1,4 +1,4 @@ -describe('Heap Test1', () => { +describe('Heap Operation Test', () => { it('should xxx', function () { expect(true).toBe(true); }); diff --git a/tests/unit/data-structures/heap/max-heap.test.ts b/tests/unit/data-structures/heap/max-heap.test.ts index 96045c6..7e9487f 100644 --- a/tests/unit/data-structures/heap/max-heap.test.ts +++ b/tests/unit/data-structures/heap/max-heap.test.ts @@ -1,6 +1,6 @@ import {HeapItem, MaxHeap} from '../../../../src'; -describe('MaxHeap Test1', () => { +describe('MaxHeap Operation Test', () => { it('should object Max Heap operations be proper', function () { const maxHeap = new MaxHeap<{ keyA: string }>(); diff --git a/tests/unit/data-structures/heap/min-heap.test.ts b/tests/unit/data-structures/heap/min-heap.test.ts index a4930f0..7eb1422 100644 --- a/tests/unit/data-structures/heap/min-heap.test.ts +++ b/tests/unit/data-structures/heap/min-heap.test.ts @@ -1,6 +1,7 @@ import {HeapItem, MinHeap} from '../../../../src'; -describe('MinHeap Test1', () => { +describe('MinHeap Operation Test', () => { + it('should numeric Min Heap operations be proper', function () { const minNumHeap = new MinHeap(); expect(minNumHeap).toBeInstanceOf(MinHeap); diff --git a/tests/unit/data-structures/priority-queue/max-priority-queue.test.ts b/tests/unit/data-structures/priority-queue/max-priority-queue.test.ts index a3367ad..cd056be 100644 --- a/tests/unit/data-structures/priority-queue/max-priority-queue.test.ts +++ b/tests/unit/data-structures/priority-queue/max-priority-queue.test.ts @@ -1,6 +1,6 @@ import {MaxPriorityQueue} from '../../../../src'; -describe('MaxPriorityQueue Test1', () => { +describe('MaxPriorityQueue Operation Test', () => { it('should add elements and maintain heap property', () => { const priorityQueue = new MaxPriorityQueue(); @@ -73,4 +73,35 @@ describe('MaxPriorityQueue Test1', () => { expect(maxPQ.poll()?.keyA).toBe(3); expect(maxPQ.poll()?.keyA).toBe(1); }); + +}); + +describe('MaxPriorityQueue Performance Test', () => { + + it('should the poll method adheres to a time complexity of O(log n) and executed correctly under large scale distinct data', () => { + const magnitude = 10000; + const nodes = Array.from(new Set(Array.from(new Array(magnitude), () => Math.floor(Math.random() * magnitude * 100)))); + expect(nodes.length).toBeGreaterThan(magnitude / 2); + const maxPQ = new MaxPriorityQueue({nodes}); + + let prev = Number.MAX_SAFE_INTEGER; + const startTime = performance.now(); + while (maxPQ.size > 0) { + const polled = maxPQ.poll(); + if (polled) { + expect(prev).toBeGreaterThan(polled); + prev = polled; + } + } + expect(performance.now() - startTime).toBeLessThan(Math.log2(magnitude) * 1000); + }); + + it('should sorted.length to be the same as original data', () => { + // const magnitude = 1000; + // const maxPriorityQueue = new MaxPriorityQueue({nodes: Array.from(new Array(magnitude), () => Math.floor(Math.random() * magnitude))}); + // const nodeCount = maxPriorityQueue.getNodes().length; + // const sorted = maxPriorityQueue.sort(); + // + // expect(sorted.length).toBe(nodeCount); // TODO Plan to support sorting of duplicate elements. + }); }); \ No newline at end of file diff --git a/tests/unit/data-structures/priority-queue/min-priority-queue.test.ts b/tests/unit/data-structures/priority-queue/min-priority-queue.test.ts index 7dc0853..0a85244 100644 --- a/tests/unit/data-structures/priority-queue/min-priority-queue.test.ts +++ b/tests/unit/data-structures/priority-queue/min-priority-queue.test.ts @@ -1,6 +1,6 @@ import {MinPriorityQueue} from '../../../../src'; -describe('MinPriorityQueue Test1', () => { +describe('MinPriorityQueue Operation Test', () => { it('should check if a node exists in the queue', () => { const priorityQueue = new MinPriorityQueue(); @@ -64,17 +64,4 @@ describe('MinPriorityQueue Test1', () => { expect(sortedArray).toEqual([1, 3, 5, 7]); }); -}); - - -describe('MinPriorityQueue Test2', () => { - it('should sorted.length to be the same as original data', () => { - // const sortCase3: number[] = Array.from(new Array(100), () => Math.floor(Math.random() * 2)); - // - // const minPriorityQueue = new MinPriorityQueue({nodes: sortCase3}); - // const nodeCount = minPriorityQueue.getNodes().length; - // const sorted = minPriorityQueue.sort(); - - // expect(sorted.length).toBe(nodeCount); // TODO Plan to support sorting of duplicate elements. - }); }); \ No newline at end of file diff --git a/tests/unit/data-structures/priority-queue/priority-queue.test.ts b/tests/unit/data-structures/priority-queue/priority-queue.test.ts index cb24f98..dd75a4f 100644 --- a/tests/unit/data-structures/priority-queue/priority-queue.test.ts +++ b/tests/unit/data-structures/priority-queue/priority-queue.test.ts @@ -1,6 +1,6 @@ import {PriorityQueue} from '../../../../src'; -describe('PriorityQueue Test1', () => { +describe('PriorityQueue Operation Test', () => { it('should validate a priority queue', () => { const minPQ = new PriorityQueue({nodes: [1, 5, 7, 9, 3, 6, 2], comparator: (a, b) => a - b}); @@ -13,4 +13,5 @@ describe('PriorityQueue Test1', () => { comparator: (a, b) => b - a })).toBe(false); }); + }); \ No newline at end of file