43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using NUnit.Framework;
|
|
using FluentAssertions;
|
|
using MoonTools.Bonk;
|
|
using System.Numerics;
|
|
|
|
namespace Tests
|
|
{
|
|
public class AABB2DTest
|
|
{
|
|
[Test]
|
|
public void Overlapping()
|
|
{
|
|
var a = new AABB2D(new Vector2(-1, -1), new Vector2(1, 1));
|
|
var b = new AABB2D(new Vector2(0, 0), new Vector2(2, 2));
|
|
|
|
AABB2D.TestOverlap(a, b).Should().BeTrue();
|
|
|
|
var c = new AABB2D(-2, -2, 2, 1);
|
|
var d = new AABB2D(-2, -2, 2, 2);
|
|
|
|
AABB2D.TestOverlap(c, d).Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void NotOverlapping()
|
|
{
|
|
var a = new AABB2D(new Vector2(-1, -1), new Vector2(1, 1));
|
|
var b = new AABB2D(new Vector2(-3, -3), new Vector2(-2, -2));
|
|
|
|
AABB2D.TestOverlap(a, b).Should().BeFalse();
|
|
}
|
|
|
|
[Test]
|
|
public void Merge()
|
|
{
|
|
var a = new AABB2D(new Vector2(-1, -2), new Vector2(2, 1));
|
|
var b = new AABB2D(new Vector2(-3, -1), new Vector2(3, 1));
|
|
|
|
a.Merge(b).Should().Be(new AABB2D(new Vector2(-3, -2), new Vector2(3, 1)));
|
|
}
|
|
}
|
|
}
|