Skip to content

Commit

Permalink
#53 Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Jul 11, 2020
1 parent 3318c05 commit ceb5dfc
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Tools/Towel_Testing/Mathematics/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,5 +1706,43 @@ namespace Towel_Testing.Mathematics
}

#endregion

#region Github Issue #53

public class MyFloat
{
private float value;
public MyFloat(float value)
{
this.value = value;
}

public static MyFloat operator *(MyFloat a, MyFloat b) => new MyFloat(a.value * b.value);
public static MyFloat operator +(MyFloat a, MyFloat b) => new MyFloat(a.value + b.value);
public static MyFloat operator /(MyFloat a, MyFloat b) => new MyFloat(a.value / b.value);
public static MyFloat operator -(MyFloat a, MyFloat b) => new MyFloat(a.value - b.value);
public static MyFloat Zero => new MyFloat(0);
public static implicit operator MyFloat(float a) => new MyFloat(a);
public static implicit operator float(MyFloat a) => a.value;
public static implicit operator MyFloat(int a) => new MyFloat(a); // this one is needed for Constant<T>.Zero
}

[TestMethod] public void GithubIssue53()
{
var a = new Matrix<MyFloat>(3, 5);
for (int i = 0; i < a.Rows; i++)
for (int j = 0; j < a.Columns; j++)
a[i, j] = 3;

var b = new Matrix<MyFloat>(5, 6);
for (int i = 0; i < b.Rows; i++)
for (int j = 0; j < b.Columns; j++)
b[i, j] = 5;

var c = a * b;
//Console.WriteLine(c);
}

#endregion
}
}

0 comments on commit ceb5dfc

Please sign in to comment.