Fixed the CurveKeyCollection class so all CurveKeyCollection test are now passing!

This commit is contained in:
SND\AstrorEnales_cp 2012-10-13 20:40:50 +00:00 committed by Konstantin Koch
parent 646c2e5b79
commit 783a448db1
5 changed files with 142 additions and 172 deletions

View File

@ -51,7 +51,8 @@ namespace ANX.Framework.TestCenter.Strukturen
#endregion #endregion
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void add(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void add(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -73,7 +74,6 @@ namespace ANX.Framework.TestCenter.Strukturen
anx.Add(new ANXCurveKey(a13, a14)); anx.Add(new ANXCurveKey(a13, a14));
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
AssertHelper.ConvertEquals(xna, anx, "add"); AssertHelper.ConvertEquals(xna, anx, "add");
} }
@ -81,11 +81,10 @@ namespace ANX.Framework.TestCenter.Strukturen
public void adde() public void adde()
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
ANXCurveKeyCollection anx = new ANXCurveKeyCollection(); ANXCurveKeyCollection anx = new ANXCurveKeyCollection();
AssertHelper.ConvertEquals(Assert.Throws<ArgumentNullException>(() => xna.Add(null)),
AssertHelper.ConvertEquals(Assert.Throws<ArgumentNullException>(delegate { xna.Add(null); }), Assert.Throws<ArgumentNullException>(delegate { anx.Add(null); }), "adde"); Assert.Throws<ArgumentNullException>(() => anx.Add(null)), "adde");
} }
//[TestCaseSource("sixteenfloats")] //[TestCaseSource("sixteenfloats")]
@ -140,9 +139,9 @@ namespace ANX.Framework.TestCenter.Strukturen
// AssertHelper.ConvertEquals(xna, anx, "add2"); // AssertHelper.ConvertEquals(xna, anx, "add2");
//} //}
[Test]
public void Constructor() public void Constructor()
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
ANXCurveKeyCollection anx = new ANXCurveKeyCollection(); ANXCurveKeyCollection anx = new ANXCurveKeyCollection();
@ -150,7 +149,8 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Clear(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Clear(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -178,7 +178,8 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Clone(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Clone(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -202,9 +203,9 @@ namespace ANX.Framework.TestCenter.Strukturen
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
ANXCurveKeyCollection anx2 = anx.Clone(); ANXCurveKeyCollection anx2 = anx.Clone();
for (int i = 0; i < xna.Count; i++) for (int index = 0; index < xna.Count; index++)
{ {
if (!(xna[i] == xna2[i])) if (xna[index] != xna2[index])
{ {
Assert.Fail(); Assert.Fail();
} }
@ -214,7 +215,8 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Contains(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Contains(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -236,13 +238,13 @@ namespace ANX.Framework.TestCenter.Strukturen
anx.Add(new ANXCurveKey(a13, a14)); anx.Add(new ANXCurveKey(a13, a14));
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
AssertHelper.ConvertEquals(xna.Contains(new XNACurveKey(a1, a2)), anx.Contains(new ANXCurveKey(a1, a2)),
AssertHelper.ConvertEquals(xna.Contains(new XNACurveKey(a1,a2)), anx.Contains(new ANXCurveKey (a1,a2)), "Contains"); "Contains");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void CopyTo(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void CopyTo(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -268,7 +270,6 @@ namespace ANX.Framework.TestCenter.Strukturen
ANXCurveKey[] anxa = new ANXCurveKey[anx.Count]; ANXCurveKey[] anxa = new ANXCurveKey[anx.Count];
anx.CopyTo(anxa, 0); anx.CopyTo(anxa, 0);
AssertHelper.ConvertEquals(xnaa, anxa, "CopyTo"); AssertHelper.ConvertEquals(xnaa, anxa, "CopyTo");
} }
@ -276,14 +277,14 @@ namespace ANX.Framework.TestCenter.Strukturen
public void IsReadOnly() public void IsReadOnly()
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
ANXCurveKeyCollection anx = new ANXCurveKeyCollection(); ANXCurveKeyCollection anx = new ANXCurveKeyCollection();
AssertHelper.ConvertEquals(xna.IsReadOnly, anx.IsReadOnly, "IsReadOnly"); AssertHelper.ConvertEquals(xna.IsReadOnly, anx.IsReadOnly, "IsReadOnly");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Remove(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Remove(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -305,12 +306,12 @@ namespace ANX.Framework.TestCenter.Strukturen
anx.Add(new ANXCurveKey(a13, a14)); anx.Add(new ANXCurveKey(a13, a14));
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
AssertHelper.ConvertEquals(xna.Remove(new XNACurveKey(a1, a2)), anx.Remove(new ANXCurveKey(a1, a2)), "Remove"); AssertHelper.ConvertEquals(xna.Remove(new XNACurveKey(a1, a2)), anx.Remove(new ANXCurveKey(a1, a2)), "Remove");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void RemoveAt(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void RemoveAt(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a1, a2)); xna.Add(new XNACurveKey(a1, a2));
@ -338,7 +339,8 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void IndexOf(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void IndexOf(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a3, a4)); xna.Add(new XNACurveKey(a3, a4));
@ -348,7 +350,7 @@ namespace ANX.Framework.TestCenter.Strukturen
xna.Add(new XNACurveKey(a11, a12)); xna.Add(new XNACurveKey(a11, a12));
xna.Add(new XNACurveKey(a13, a14)); xna.Add(new XNACurveKey(a13, a14));
xna.Add(new XNACurveKey(a15, a16)); xna.Add(new XNACurveKey(a15, a16));
xna[0] = (new XNACurveKey(a1, a2)); xna[0] = new XNACurveKey(a1, a2);
ANXCurveKeyCollection anx = new ANXCurveKeyCollection(); ANXCurveKeyCollection anx = new ANXCurveKeyCollection();
anx.Add(new ANXCurveKey(a3, a4)); anx.Add(new ANXCurveKey(a3, a4));
@ -358,14 +360,14 @@ namespace ANX.Framework.TestCenter.Strukturen
anx.Add(new ANXCurveKey(a11, a12)); anx.Add(new ANXCurveKey(a11, a12));
anx.Add(new ANXCurveKey(a13, a14)); anx.Add(new ANXCurveKey(a13, a14));
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
anx[0] = (new ANXCurveKey(a1, a2)); anx[0] = new ANXCurveKey(a1, a2);
AssertHelper.ConvertEquals(xna.IndexOf(new XNACurveKey(a1, a2)), anx.IndexOf(new ANXCurveKey(a1, a2)), "IndexOf"); AssertHelper.ConvertEquals(xna.IndexOf(new XNACurveKey(a1, a2)), anx.IndexOf(new ANXCurveKey(a1, a2)), "IndexOf");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void GetEnumerator(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void GetEnumerator(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKeyCollection xna = new XNACurveKeyCollection(); XNACurveKeyCollection xna = new XNACurveKeyCollection();
xna.Add(new XNACurveKey(a3, a4)); xna.Add(new XNACurveKey(a3, a4));
@ -375,26 +377,19 @@ namespace ANX.Framework.TestCenter.Strukturen
xna.Add(new XNACurveKey(a11, a12)); xna.Add(new XNACurveKey(a11, a12));
xna.Add(new XNACurveKey(a13, a14)); xna.Add(new XNACurveKey(a13, a14));
xna.Add(new XNACurveKey(a15, a16)); xna.Add(new XNACurveKey(a15, a16));
xna[0] = (new XNACurveKey(a1, a2)); xna[0] = new XNACurveKey(a1, a2);
ANXCurveKeyCollection anx = new ANXCurveKeyCollection(); ANXCurveKeyCollection anx = new ANXCurveKeyCollection();
anx.Add(new ANXCurveKey(a3, a4)); anx.Add(new ANXCurveKey(a3, a4));
anx.Add(new ANXCurveKey(a5, a6)); anx.Add(new ANXCurveKey(a5, a6));
anx.Add(new ANXCurveKey(a7, a8)); anx.Add(new ANXCurveKey(a7, a8));
anx.Add(new ANXCurveKey(a9, a10)); anx.Add(new ANXCurveKey(a9, a10));
anx.Add(new ANXCurveKey(a11, a12)); anx.Add(new ANXCurveKey(a11, a12));
anx.Add(new ANXCurveKey(a13, a14)); anx.Add(new ANXCurveKey(a13, a14));
anx.Add(new ANXCurveKey(a15, a16)); anx.Add(new ANXCurveKey(a15, a16));
anx[0] = (new ANXCurveKey(a1, a2)); anx[0] = new ANXCurveKey(a1, a2);
foreach (var item in anx)
{ AssertHelper.ConvertEquals(xna, anx, "GetEnumerator");
}
AssertHelper.ConvertEquals(xna, anx, "GetEnumerator");
} }
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements #region Using Statements
using System; using System;
using System.IO;
using ANX.Framework.NonXNA;
using NUnit.Framework; using NUnit.Framework;
#endregion // Using Statements #endregion // Using Statements
@ -23,10 +21,10 @@ using ANXCurveTangent = ANX.Framework.CurveTangent;
using XNACurveContinuity = Microsoft.Xna.Framework.CurveContinuity; using XNACurveContinuity = Microsoft.Xna.Framework.CurveContinuity;
using ANXCurveContinuity = ANX.Framework.CurveContinuity; using ANXCurveContinuity = ANX.Framework.CurveContinuity;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
namespace ANX.Framework.TestCenter.Strukturen namespace ANX.Framework.TestCenter.Strukturen
{ {
[TestFixture] [TestFixture]
@ -62,7 +60,8 @@ namespace ANX.Framework.TestCenter.Strukturen
#endregion #endregion
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Constructor(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Constructor(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2); XNACurveKey xna = new XNACurveKey(a1, a2);
ANXCurveKey anx = new ANXCurveKey(a1, a2); ANXCurveKey anx = new ANXCurveKey(a1, a2);
@ -71,7 +70,8 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Constructor2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Constructor2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
@ -80,7 +80,9 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloatsCurve")] [TestCaseSource("sixteenfloatsCurve")]
public void Constructor3(XNACurveContinuity xnacurve, ANXCurveContinuity anxcurve, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Constructor3(XNACurveContinuity xnacurve, ANXCurveContinuity anxcurve, float a1, float a2, float a3,
float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14,
float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4, xnacurve); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4, xnacurve);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4, anxcurve); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4, anxcurve);
@ -89,83 +91,86 @@ namespace ANX.Framework.TestCenter.Strukturen
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void Clone(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void Clone(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10,
float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = xna.Clone(); XNACurveKey xna2 = xna.Clone();
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = anx.Clone(); ANXCurveKey anx2 = anx.Clone();
AssertHelper.ConvertEquals(xna, anx, xna2, anx2, "Clone"); AssertHelper.ConvertEquals(xna, anx, xna2, anx2, "Clone");
} }
[TestCaseSource("sixteenfloats2")] [TestCaseSource("sixteenfloats2")]
public void CompareTo(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void CompareTo(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna.CompareTo(xna2), anx.CompareTo(anx2), "CompareTo"); AssertHelper.ConvertEquals(xna.CompareTo(xna2), anx.CompareTo(anx2), "CompareTo");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void op_Equality(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void op_Equality(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna==xna2, anx==anx2, "op_Equality"); AssertHelper.ConvertEquals(xna==xna2, anx==anx2, "op_Equality");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void op_Equality2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void op_Equality2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna == xna2, anx == anx2, "op_Equality2"); AssertHelper.ConvertEquals(xna == xna2, anx == anx2, "op_Equality2");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void op_Unequality(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void op_Unequality(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "op_Unequality"); AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "op_Unequality");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void op_Unequality2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void op_Unequality2(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "op_Unequality2"); AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "op_Unequality2");
} }
[TestCaseSource("sixteenfloats")] [TestCaseSource("sixteenfloats")]
public void GetHashCode(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16) public void GetHashCode(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9,
float a10, float a11, float a12, float a13, float a14, float a15, float a16)
{ {
XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4); XNACurveKey xna = new XNACurveKey(a1, a2, a3, a4);
XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4); XNACurveKey xna2 = new XNACurveKey(a2, a1, a3, a4);
ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4); ANXCurveKey anx = new ANXCurveKey(a1, a2, a3, a4);
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4); ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna.GetHashCode(), anx.GetHashCode(), "GetHashCode"); AssertHelper.ConvertEquals(xna.GetHashCode(), anx.GetHashCode(), "GetHashCode");
} }
} }

View File

@ -12,7 +12,7 @@ namespace ANX.Framework
#endif #endif
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("floAr")] [Developer("floAr")]
[TestState(TestStateAttribute.TestState.InProgress)] [TestState(TestStateAttribute.TestState.Tested)]
public class Curve public class Curve
{ {
public CurveLoopType PreLoop { get; set; } public CurveLoopType PreLoop { get; set; }

View File

@ -9,40 +9,16 @@ namespace ANX.Framework
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("???")] [Developer("???")]
[TestState(TestStateAttribute.TestState.InProgress)] [TestState(TestStateAttribute.TestState.Tested)]
public class CurveKey : IEquatable<CurveKey>, IComparable<CurveKey> public class CurveKey : IEquatable<CurveKey>, IComparable<CurveKey>
{ {
#region Public #region Public
public float Position public float Position { get; private set; }
{ public float Value { get; set; }
get; public float TangentIn { get; set; }
private set; public float TangentOut { get; set; }
} public CurveContinuity Continuity { get; set; }
#endregion
public float Value
{
get;
set;
}
public float TangentIn
{
get;
set;
}
public float TangentOut
{
get;
set;
}
public CurveContinuity Continuity
{
get;
set;
}
#endregion
#region Constructor #region Constructor
public CurveKey(float position, float value) public CurveKey(float position, float value)
@ -50,14 +26,12 @@ namespace ANX.Framework
{ {
} }
public CurveKey(float position, float value, float tangentIn, public CurveKey(float position, float value, float tangentIn, float tangentOut)
float tangentOut)
: this(position, value, tangentIn, tangentOut, CurveContinuity.Smooth) : this(position, value, tangentIn, tangentOut, CurveContinuity.Smooth)
{ {
} }
public CurveKey(float position, float value, float tangentIn, public CurveKey(float position, float value, float tangentIn, float tangentOut, CurveContinuity continuity)
float tangentOut, CurveContinuity continuity)
{ {
Position = position; Position = position;
Value = value; Value = value;
@ -91,14 +65,9 @@ namespace ANX.Framework
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj == null && obj.GetType() == typeof(CurveKey)) return obj is CurveKey && this == (CurveKey)obj;
{
return this == (CurveKey)obj;
}
return false;
} }
#endregion #endregion
#region GetHashCode #region GetHashCode
public override int GetHashCode() public override int GetHashCode()
@ -113,14 +82,10 @@ namespace ANX.Framework
public static bool operator ==(CurveKey a, CurveKey b) public static bool operator ==(CurveKey a, CurveKey b)
{ {
if (null == a as Object) if (null == a as Object)
{
return null == b as Object; return null == b as Object;
}
if (null == b as Object) if (null == b as Object)
{ return false;
return null == a as Object;
}
return a.Position == b.Position && return a.Position == b.Position &&
a.Value == b.Value && a.Value == b.Value &&
@ -134,14 +99,10 @@ namespace ANX.Framework
public static bool operator !=(CurveKey a, CurveKey b) public static bool operator !=(CurveKey a, CurveKey b)
{ {
if (null == a as Object) if (null == a as Object)
{
return null != b as Object; return null != b as Object;
}
if (null == b as Object) if (null == b as Object)
{ return true;
return null != a as Object;
}
return a.Position != b.Position || return a.Position != b.Position ||
a.Value != b.Value || a.Value != b.Value ||
@ -152,17 +113,13 @@ namespace ANX.Framework
#endregion #endregion
#region CompareTo #region CompareTo
public int CompareTo(CurveKey other) public int CompareTo(CurveKey other)
{ {
if (Position == other.Position) if (Position == other.Position)
{ return 0;
return 0;
}
return Position >= other.Position ? return Position >= other.Position ? 1 : -1;
1 : }
-1; #endregion
}
#endregion
} }
} }

View File

@ -10,8 +10,8 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework namespace ANX.Framework
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("???")] [Developer("???, AstrorEnales")]
[TestState(TestStateAttribute.TestState.InProgress)] [TestState(TestStateAttribute.TestState.Tested)]
public class CurveKeyCollection : ICollection<CurveKey>, IEnumerable<CurveKey>, IEnumerable public class CurveKeyCollection : ICollection<CurveKey>, IEnumerable<CurveKey>, IEnumerable
{ {
#region Private #region Private
@ -19,23 +19,17 @@ namespace ANX.Framework
#endregion #endregion
#region Public #region Public
public int Count public int Count
{ {
get get { return keys.Count; }
{ }
return keys.Count;
}
}
public bool IsReadOnly public bool IsReadOnly
{ {
get get { return false; }
{ }
return false;
}
}
public CurveKey this[int index] public CurveKey this[int index]
{ {
get get
{ {
@ -48,6 +42,7 @@ namespace ANX.Framework
if (index >= keys.Count) if (index >= keys.Count)
throw new IndexOutOfRangeException(); throw new IndexOutOfRangeException();
//if fitting add here //if fitting add here
if (keys[index].Position == value.Position) if (keys[index].Position == value.Position)
keys[index] = value; keys[index] = value;
@ -55,7 +50,7 @@ namespace ANX.Framework
{ {
//if not let it be sorted //if not let it be sorted
keys.RemoveAt(index); keys.RemoveAt(index);
keys.Add(value); Add(value);
} }
} }
@ -73,42 +68,61 @@ namespace ANX.Framework
public void Add(CurveKey item) public void Add(CurveKey item)
{ {
if (item == null) if (item == null)
{
throw new ArgumentNullException(); throw new ArgumentNullException();
}
// keys.Add(item);
if (this.keys.Count == 0) // If the list is empty or the item is bigger than the max, just add it
if (keys.Count == 0 || item.CompareTo(keys[Count - 1]) > 0)
{ {
//No list items keys.Add(item);
this.keys.Add(item);
return; return;
} }
if (item.CompareTo(this[Count - 1]) > 0)
int index = keys.BinarySearch(item);
if(index == -1)
{ {
//Bigger than Max index = ~index;
this.keys.Add(item); keys.Insert(index, item);
return; return;
} }
int min = 0;
int max = Count - 1; while (index < keys.Count)
while ((max - min) > 1)
{ {
//Find half point if (item.Position != keys[index].Position)
int half = min + ((max - min) / 2); break;
//Compare if it's bigger or smaller than the current item.
int comp = item.CompareTo(this[half]); index++;
if (comp == 0)
{
//Item is equal to half point
this.keys.Insert(half+1, item);
return;
}
else if (comp < 0) max = half; //Item is smaller
else min = half; //Item is bigger
} }
if (item.CompareTo(this[min]) <= 0) this.keys.Insert(min, item);
else this.keys.Insert(min + 1, item); keys.Insert(index, item);
// Old broken code with own binary search implementation.
// Just in case the binary search isn't available on any system, this can be fixed:
//int min = 0;
//int max = Count - 1;
//while ((max - min) > 1)
//{
// //Find half point
// int half = min + ((max - min) / 2);
// //Compare if it's bigger or smaller than the current item.
// int comp = item.CompareTo(keys[half]);
// if (comp == 0)
// {
// // Item is equal to half point
// keys.Insert(half + 1, item);
// return;
// }
// // If the item is smaller, move the max to half, otherwise move the min to half.
// if (comp == -1)
// max = half;
// else
// min = half;
//}
//if (item.CompareTo(keys[min]) <= 0)
// keys.Insert(min, item);
//else
// keys.Insert(min + 1, item);
} }
#endregion #endregion
@ -158,12 +172,11 @@ namespace ANX.Framework
#region Clone #region Clone
public CurveKeyCollection Clone() public CurveKeyCollection Clone()
{ {
CurveKeyCollection result = new CurveKeyCollection(); return new CurveKeyCollection
foreach (CurveKey key in this.keys) {
result.Add(key); keys = new List<CurveKey>(keys),
return result; };
} }
#endregion #endregion