GeezerVison is showing github.com — merge: Add test case to ConvexHullGraham Algorithm (#938) · ex1234/JavaScript@9d2a7f1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +29Lines changed: 29 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { convexHull } from '../ConvexHullGraham' | | 2 | + | | 3 | +test('The ConvexHull of the following points is [{x: 0, y: 3}, {x: 4, y: 4}, {x: 3, y: 1}, {x: 0, y: 0}]', () => { | | 4 | + const points = [ | | 5 | + { x: 0, y: 3 }, | | 6 | + { x: 1, y: 1 }, | | 7 | + { x: 2, y: 2 }, | | 8 | + { x: 4, y: 4 }, | | 9 | + { x: 0, y: 0 }, | | 10 | + { x: 1, y: 2 }, | | 11 | + { x: 3, y: 1 }, | | 12 | + { x: 3, y: 3 }] | | 13 | + const res = convexHull(points) | | 14 | + expect(res).toEqual([{ x: 0, y: 3 }, { x: 4, y: 4 }, { x: 3, y: 1 }, { x: 0, y: 0 }]) | | 15 | +}) | | 16 | + | | 17 | +test('The ConvexHull of the following points is [{x: 1, y: 4}, {x: 9, y: 6}, {x: 7, y: 0}, {x: 0, y: 0}]', () => { | | 18 | + const points = [ | | 19 | + { x: 4, y: 3 }, | | 20 | + { x: 1, y: 4 }, | | 21 | + { x: 2, y: 4 }, | | 22 | + { x: 0, y: 0 }, | | 23 | + { x: 9, y: 6 }, | | 24 | + { x: 1, y: 3 }, | | 25 | + { x: 4, y: 1 }, | | 26 | + { x: 7, y: 0 }] | | 27 | + const res = convexHull(points) | | 28 | + expect(res).toEqual([{ x: 1, y: 4 }, { x: 9, y: 6 }, { x: 7, y: 0 }, { x: 0, y: 0 }]) | | 29 | +}) |
|