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

Diff for: Graphs/test/TarjanSCC.test.js

+20
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)