From b53d4f39f88a4fcc9011d5cdc4dafe33aeac8aa6 Mon Sep 17 00:00:00 2001 From: Ankush263 Date: Mon, 21 Mar 2022 15:04:49 +0530 Subject: [PATCH] Add test case to ConvexHullGraham Algorithm --- Geometry/Test/ConvexHullGraham.test.js | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Geometry/Test/ConvexHullGraham.test.js diff --git a/Geometry/Test/ConvexHullGraham.test.js b/Geometry/Test/ConvexHullGraham.test.js new file mode 100644 index 0000000000..747f995538 --- /dev/null +++ b/Geometry/Test/ConvexHullGraham.test.js @@ -0,0 +1,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 }]) +}) 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