Skip to content

Commit a39bbde

Browse files
committed
improve test
1 parent 4b20c54 commit a39bbde

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -678,17 +678,16 @@ public void TestBoneWeightExport(string fbxPath){
678678
Debug.LogWarningFormat ("Compared {0} out of a possible {1} bone weights", comparisonCount, minVertCount);
679679
}
680680

681-
public static void AreNearEqual(Vector3 a, Vector3 b)
682-
{
683-
Assert.That(a.x, Is.EqualTo(b.x).Within(0.0001f));
684-
Assert.That(a.y, Is.EqualTo(b.y).Within(0.0001f));
685-
Assert.That(a.z, Is.EqualTo(b.z).Within(0.0001f));
686-
}
687-
public static void AreNearEqual(Vector3[] a, Vector3[] b)
681+
682+
public class Vector3Comparer : IComparer<Vector3>
688683
{
689-
Assert.AreEqual(a.Length, b.Length);
690-
for (int i = 0; i < a.Length; ++i)
691-
AreNearEqual(a[i], b[i]);
684+
public int Compare(Vector3 a, Vector3 b)
685+
{
686+
Assert.That(a.x, Is.EqualTo(b.x).Within(0.00001f));
687+
Assert.That(a.y, Is.EqualTo(b.y).Within(0.00001f));
688+
Assert.That(a.z, Is.EqualTo(b.z).Within(0.00001f));
689+
return 0; // we're almost equal
690+
}
692691
}
693692

694693
[Test]
@@ -722,11 +721,11 @@ public void TestBlendShapeExport()
722721
var originalMesh = originalSMR.sharedMesh;
723722
var exportedMesh = exportedSMR.sharedMesh;
724723
Assert.IsNotNull(originalMesh);
725-
Assert.IsNotNull(exportedMesh);
726-
727-
// compare blend shape data
724+
Assert.IsNotNull(exportedMesh);
725+
726+
// compare blend shape data
727+
Assert.AreNotEqual(originalMesh.blendShapeCount, 0);
728728
Assert.AreEqual(originalMesh.blendShapeCount, exportedMesh.blendShapeCount);
729-
if (originalMesh.blendShapeCount > 0)
730729
{
731730
var deltaVertices = new Vector3[originalMesh.vertexCount];
732731
var deltaNormals = new Vector3[originalMesh.vertexCount];
@@ -747,9 +746,11 @@ public void TestBlendShapeExport()
747746

748747
originalMesh.GetBlendShapeFrameVertices(bi, fi, deltaVertices, deltaNormals, deltaTangents);
749748
exportedMesh.GetBlendShapeFrameVertices(bi, fi, fbxDeltaVertices, fbxDeltaNormals, fbxDeltaTangents);
750-
AreNearEqual(deltaVertices, fbxDeltaVertices);
751-
AreNearEqual(deltaNormals, fbxDeltaNormals);
752-
AreNearEqual(deltaTangents, fbxDeltaTangents);
749+
750+
var v3comparer = new Vector3Comparer();
751+
Assert.That(deltaVertices, Is.EqualTo(fbxDeltaVertices).Using<Vector3>(v3comparer), string.Format("delta vertices don't match"));
752+
Assert.That(deltaNormals, Is.EqualTo(fbxDeltaNormals).Using<Vector3>(v3comparer), string.Format("delta normals don't match"));
753+
Assert.That(deltaTangents, Is.EqualTo(fbxDeltaTangents).Using<Vector3>(v3comparer), string.Format("delta tangents don't match"));
753754

754755
}
755756
}

0 commit comments

Comments
 (0)