Skip to content

Commit 9d2a7f1

Browse files
authored
merge: Add test case to ConvexHullGraham Algorithm (#938)
1 parent 9f7ed56 commit 9d2a7f1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy