VEHwang's picture
Upload CoCogni4D-Bench (questions, media, scripts, render records, code) (part 4)
9d57416 verified
Raw History Blame Contribute Delete
627 Bytes
import test from 'node:test';
import assert from 'node:assert/strict';
import {intersects, pointInside} from '../src/layout.ts';
test('label rectangle overlap rejects touching interiors and permits separated text', () => {
const first = {left: 0, top: 0, right: 20, bottom: 10};
assert.equal(intersects(first, {left: 21, top: 0, right: 40, bottom: 10}), false);
assert.equal(intersects(first, {left: 10, top: 0, right: 30, bottom: 10}), true);
const room: [number, number][] = [[0, 0], [10, 0], [10, 10], [0, 10]];
assert.equal(pointInside([5, 5], room), true);
assert.equal(pointInside([15, 5], room), false);
});