Skip to content

Commit ae3b7fb

Browse files
committed
Added a few edge test cases
1 parent 0a18f10 commit ae3b7fb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Graphs/test/TarjanSCC.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,23 @@ test('Test Case 4 - Complex Graph', () => {
7070

7171
expect(actual).toEqual(expect.arrayContaining(expected))
7272
})
73+
74+
test('Edge Case - Null input should throw error', () => {
75+
expect(() => TarjanSCC(null)).toThrow(
76+
'Graph must be a non-null object representing an adjacency list'
77+
)
78+
})
79+
80+
test('Edge Case - Node with non-array neighbors should throw error', () => {
81+
const graph = {
82+
A: 'not-an-array'
83+
}
84+
expect(() => TarjanSCC(graph)).toThrow('Neighbors of node A must be an array')
85+
})
86+
87+
test('Edge Case - Neighbor not in graph should throw error', () => {
88+
const graph = {
89+
A: ['B']
90+
}
91+
expect(() => TarjanSCC(graph)).toThrow('Node B not found in graph')
92+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy