Skip to content

Commit 4a07417

Browse files
committed
Update bfs test case
1 parent a03e327 commit 4a07417

File tree

1 file changed

+3
-41
lines changed

1 file changed

+3
-41
lines changed

test/graphs/searching/bfs.spec.js

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,12 @@ var sampleGraph = [[1, 1, 1, 0, 0, 0],
99
[0, 0, 1, 1, 1, 1],
1010
[0, 0, 0, 0, 1, 1]];
1111

12-
var bfs = require('../../../src/graphs/searching/bfs').breadthFirstSearch;
12+
var bfs = require('../../../src/graphs/searching/bfs').bfs;
1313

1414
describe('BFS', function () {
1515

16-
it('should work with incorrect input', function () {
17-
expect(function () {
18-
bfs(null, [1, 1], [1, 1]);
19-
}).toThrow();
20-
expect(function () {
21-
bfs(sampleGraph, [-1, -1], [0, 0]);
22-
}).toThrow();
23-
expect(function () {
24-
bfs(sampleGraph, [0, -1], [-1, 0]);
25-
}).toThrow();
26-
expect(function () {
27-
bfs(sampleGraph, [0, 0], [-1, 0]);
28-
}).toThrow();
29-
expect(function () {
30-
bfs(sampleGraph, [0, 1000], [-1, 0]);
31-
}).toThrow();
32-
expect(function () {
33-
bfs(sampleGraph, [100000, 1000], [-1, 0]);
34-
}).toThrow();
35-
expect(function () {
36-
bfs(sampleGraph, [0, 0], [100, 100]);
37-
}).toThrow();
38-
expect(function () {
39-
bfs(sampleGraph, [0, 0], [5, 5]);
40-
}).not.toThrow();
41-
});
42-
43-
it('should work with 1x1 matrix', function () {
44-
var graph = [[1]];
45-
expect(bfs(graph, [0, 0], [0, 0])).toBeTruthy();
46-
graph = [[0]];
47-
expect(bfs(graph, [0, 0], [0, 0])).toBeFalsy();
48-
});
49-
50-
it('should work in the general case', function () {
51-
expect(bfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy();
52-
expect(bfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy();
53-
expect(bfs(sampleGraph, [0, 0], [0, 5])).toBeFalsy();
54-
expect(bfs(sampleGraph, [1, 1], [6, 5])).toBeTruthy();
55-
expect(bfs(sampleGraph, [1, 1], [0, 5])).toBeFalsy();
16+
it('should work with empty graph', function () {
17+
expect(bfs([], 0, 0)).toEqual([0]);
5618
});
5719

5820
});

0 commit comments

Comments
 (0)