mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Revert: Update test.js
This commit is contained in:
@@ -5,19 +5,17 @@ export default {
|
|||||||
// - You MUST use a dynamic import() to load the 'js-priority-queue' library from a CDN for the priority queue.
|
// - You MUST use a dynamic import() to load the 'js-priority-queue' library from a CDN for the priority queue.
|
||||||
// - The function should return the total weight of the shortest path, or Infinity if no path exists.
|
// - The function should return the total weight of the shortest path, or Infinity if no path exists.
|
||||||
// - Graph format: { 'A': { 'B': 1, 'C': 4 }, 'B': { ... }, ... }`,
|
// - Graph format: { 'A': { 'B': 1, 'C': 4 }, 'B': { ... }, ... }`,
|
||||||
getTestCases: () => {
|
|
||||||
const graph = {
|
|
||||||
A: { B: 2, C: 5 }, B: { A: 2, C: 6, D: 1, E: 3 }, C: { A: 5, B: 6, F: 8 },
|
|
||||||
D: { B: 1, E: 4 }, E: { B: 3, D: 4, F: 2 }, F: { C: 8, E: 2 }
|
|
||||||
};
|
|
||||||
return [graph, 'A', 'F'];
|
|
||||||
},
|
|
||||||
runTest: async (findShortestPath) => {
|
runTest: async (findShortestPath) => {
|
||||||
const assert = {
|
const assert = {
|
||||||
strictEqual: (a, e, m) => { if (a !== e) throw new Error(m || `FAIL: ${a} !== ${e}`) },
|
strictEqual: (a, e, m) => { if (a !== e) throw new Error(m || `FAIL: ${a} !== ${e}`) },
|
||||||
};
|
};
|
||||||
const [graph, start, end] = globalThis.getTestCases ? globalThis.getTestCases() : this.getTestCases();
|
const graph = {
|
||||||
const dist = await findShortestPath(graph, start, end);
|
A: { B: 2, C: 5 }, B: { A: 2, C: 6, D: 1, E: 3 }, C: { A: 5, B: 6, F: 8 },
|
||||||
|
D: { B: 1, E: 4 }, E: { B: 3, D: 4, F: 2 }, F: { C: 8, E: 2 }
|
||||||
|
};
|
||||||
|
const dist = await findShortestPath(graph, 'A', 'F');
|
||||||
assert.strictEqual(dist, 7, "Test Failed: Path A to F should be 7.");
|
assert.strictEqual(dist, 7, "Test Failed: Path A to F should be 7.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user