fixed Equality operators in CurveKey and Unit tests

This commit is contained in:
Glatzemann 2011-11-21 07:44:02 +00:00
parent 3c25f845c4
commit 7251ab8fcb
2 changed files with 15 additions and 14 deletions

View File

@ -178,7 +178,7 @@ namespace ANX.Framework.TestCenter.Strukturen
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna == null, anx == null, "op_Equality2");
AssertHelper.ConvertEquals(xna == xna2, anx == anx2, "op_Equality2");
}
[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)
@ -200,7 +200,7 @@ namespace ANX.Framework.TestCenter.Strukturen
ANXCurveKey anx2 = new ANXCurveKey(a2, a1, a3, a4);
AssertHelper.ConvertEquals(xna != null, anx != null, "op_Unequality2");
AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "op_Unequality2");
}
[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)

View File

@ -130,10 +130,9 @@ namespace ANX.Framework
public override bool Equals(object obj)
{
CurveKey ck = obj as CurveKey;
if (ck != null)
if (obj == null && obj.GetType() == typeof(CurveKey))
{
return Equals(ck);
return this == (CurveKey)obj;
}
return false;
@ -152,20 +151,22 @@ namespace ANX.Framework
#region Equality
public static bool operator ==(CurveKey a, CurveKey b)
{
return a.Equals(b);
}
return a.Position == b.Position &&
a.Value == b.Value &&
a.TangentIn == b.TangentIn &&
a.TangentOut == b.TangentOut &&
a.Continuity == b.Continuity;
}
#endregion
#region Inequality
public static bool operator !=(CurveKey a, CurveKey b)
{
return !a.Equals(b);
/*return a.Position != b.Position ||
a.Value != b.Value ||
a.TangentIn != b.TangentIn ||
a.TangentOut != b.TangentOut ||
a.Continuity != b.Continuity;*/
return a.Position != b.Position ||
a.Value != b.Value ||
a.TangentIn != b.TangentIn ||
a.TangentOut != b.TangentOut ||
a.Continuity != b.Continuity;
}
#endregion