Skip to content

Commit

Permalink
try to fix inconsistent test behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Jul 8, 2018
1 parent 56596ab commit 4187c93
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion dotnet/Serpent/Tests/SerializeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,23 @@ public class SerializeTestClass
public string s {get; set;}
public int i {get; set;}
public object obj {get; set;}


protected bool Equals(SerializeTestClass other)
{
return x == other.x && string.Equals(s, other.s) && i == other.i && Equals(obj, other.obj);
}

public override int GetHashCode()
{
unchecked
{
int hashCode = x;
hashCode = (hashCode * 397) ^ (s != null ? s.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ i;
hashCode = (hashCode * 397) ^ (obj != null ? obj.GetHashCode() : 0);
return hashCode;
}
}
}

[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
Expand All @@ -745,5 +761,21 @@ public struct SerializeTestStruct
public int x;
public string s {get; set;}
public int i {get; set;}

public bool Equals(SerializeTestStruct other)
{
return x == other.x && string.Equals(s, other.s) && i == other.i;
}

public override int GetHashCode()
{
unchecked
{
int hashCode = x;
hashCode = (hashCode * 397) ^ (s != null ? s.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ i;
return hashCode;
}
}
}
}

0 comments on commit 4187c93

Please sign in to comment.