Tests: LargestAbsoluteComponentIndex test to reproduce #2674

This commit is contained in:
vis2k 2021-08-07 21:24:10 +08:00
parent 3d67c72336
commit c5080d1ab3

View File

@ -28,6 +28,15 @@ public void LargestAbsoluteComponentIndex()
Assert.That(index, Is.EqualTo(0));
Assert.That(largest, Is.EqualTo(Mathf.Abs(value.x)));
Assert.That(withoutLargest, Is.EqualTo(new Vector3(value.y, value.z, value.w)));
// test to guarantee it uses 'abs' for first value
// to reproduce https://github.com/vis2k/Mirror/issues/2674
// IF all values are properly 'abs', THEN first one should be largest
value = new Vector4(-3, 0, 1, 2);
index = Compression.LargestAbsoluteComponentIndex(value, out largest, out withoutLargest);
Assert.That(index, Is.EqualTo(0));
Assert.That(largest, Is.EqualTo(Mathf.Abs(value.x)));
Assert.That(withoutLargest, Is.EqualTo(new Vector3(value.y, value.z, value.w)));
}
[Test, Ignore("Enable when needed.")]