forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvexHullGraham.test.js
More file actions
29 lines (27 loc) · 916 Bytes
/
ConvexHullGraham.test.js
File metadata and controls
29 lines (27 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { convexHull } from '../ConvexHullGraham'
test('The ConvexHull of the following points is [{x: 0, y: 3}, {x: 4, y: 4}, {x: 3, y: 1}, {x: 0, y: 0}]', () => {
const points = [
{ x: 0, y: 3 },
{ x: 1, y: 1 },
{ x: 2, y: 2 },
{ x: 4, y: 4 },
{ x: 0, y: 0 },
{ x: 1, y: 2 },
{ x: 3, y: 1 },
{ x: 3, y: 3 }]
const res = convexHull(points)
expect(res).toEqual([{ x: 0, y: 3 }, { x: 4, y: 4 }, { x: 3, y: 1 }, { x: 0, y: 0 }])
})
test('The ConvexHull of the following points is [{x: 1, y: 4}, {x: 9, y: 6}, {x: 7, y: 0}, {x: 0, y: 0}]', () => {
const points = [
{ x: 4, y: 3 },
{ x: 1, y: 4 },
{ x: 2, y: 4 },
{ x: 0, y: 0 },
{ x: 9, y: 6 },
{ x: 1, y: 3 },
{ x: 4, y: 1 },
{ x: 7, y: 0 }]
const res = convexHull(points)
expect(res).toEqual([{ x: 1, y: 4 }, { x: 9, y: 6 }, { x: 7, y: 0 }, { x: 0, y: 0 }])
})