UNPKG

rulyotano.math.geometry

Version:
44 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Point_1 = require("../Point"); describe('src > Point', () => { beforeEach(() => { }); afterEach(() => { }); const x = 3.4; const y = 9.3; test('Constructor should initialize x and y', () => { const point = new Point_1.default(x, y); expect(point.x).toBe(x); expect(point.y).toBe(y); }); describe('Equal method', () => { [ [0, 1, 0, 1, true], [2, 1, 0, 1, false], [0, 1, 2, 1, false], [0, 2, 0, 1, false], [0, 1, 0, 2, false], [0.000000001, 1.000000001, 0, 1, true], ].forEach(testCase => { test(`When x and y both are equals, points should be true. False other wise. p1(${testCase[0]}, ${testCase[1]}), p2(${testCase[2]}, ${testCase[3]}) => expected: ${testCase[4]}`, () => { const p1 = new Point_1.default(testCase[0], testCase[1]); const p2 = new Point_1.default(testCase[2], testCase[3]); const expected = testCase[4]; expect(p1.equals(p2)).toBe(expected); }); }); }); describe('getHashCode', () => { test('Two points with same value should get same getHashCode', () => { const p1 = new Point_1.default(x, y); const p2 = new Point_1.default(x, y); expect(p1.getHashCode()).toBe(p2.getHashCode()); }); test('Two points with different values should get different getHashCodes', () => { const p1 = new Point_1.default(x, y); const p2 = new Point_1.default(x, y + 1); expect(p1.getHashCode()).not.toBe(p2.getHashCode()); }); }); }); //# sourceMappingURL=point.test.js.map