Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d2a7f1

Browse files
merge: Add test case to ConvexHullGraham Algorithm (TheAlgorithms#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)

AltStyle によって変換されたページ (->オリジナル) /