MoonTools.Bonk/Test/AABB3DTest.cs

43 lines
1.2 KiB
C#

using NUnit.Framework;
using FluentAssertions;
using MoonTools.Bonk;
using System.Numerics;
namespace Tests
{
public class AABB3DTest
{
[Test]
public void Overlapping()
{
var a = new AABB3D(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
var b = new AABB3D(new Vector3(0, 0, 0), new Vector3(2, 2, 2));
AABB3D.TestOverlap(a, b).Should().BeTrue();
var c = new AABB3D(-2, -2, 2, 2, 1, 2);
var d = new AABB3D(-2, -2, 2, 2, 2, 2);
AABB3D.TestOverlap(c, d).Should().BeTrue();
}
[Test]
public void NotOverlapping()
{
var a = new AABB3D(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
var b = new AABB3D(new Vector3(-3, -3, -3), new Vector3(-2, -2, -1));
AABB3D.TestOverlap(a, b).Should().BeFalse();
}
[Test]
public void Merge()
{
var a = new AABB3D(new Vector3(-1, -1, -1), new Vector3(2, 2, 2));
var b = new AABB3D(new Vector3(-2, -2, -1), new Vector3(3, 1, 3));
a.Merge(b).Should().Be(new AABB3D(new Vector3(-2, -2, -1), new Vector3(3, 2, 3)));
}
}
}