public void ConstructorValuesAreAccessibleByIndexer() { Matrix1x4 matrix1x4; matrix1x4 = new Matrix1x4(); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { Assert.AreEqual(0, matrix1x4[x, y], Epsilon); } } double value = 33.33; matrix1x4 = new Matrix1x4(value); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { Assert.AreEqual(value, matrix1x4[x, y], Epsilon); } } GenerateFilledMatrixWithValues(out matrix1x4); for (int y = 0; y < matrix1x4.Rows; y++) { for (int x = 0; x < matrix1x4.Columns; x++) { Assert.AreEqual(y * matrix1x4.Columns + x, matrix1x4[x, y], Epsilon); } } }
public void ConstantValuesAreCorrect() { Matrix1x4 matrix1x4 = new Matrix1x4(); Assert.AreEqual(1, matrix1x4.Columns); Assert.AreEqual(4, matrix1x4.Rows); Assert.AreEqual(Matrix1x4.ColumnCount, matrix1x4.Columns); Assert.AreEqual(Matrix1x4.RowCount, matrix1x4.Rows); }
public void MuliplyByMatrix3x1ProducesMatrix3x4() { Matrix1x4 matrix1 = new Matrix1x4(3); Matrix3x1 matrix2 = new Matrix3x1(2); Matrix3x4 result = matrix1 * matrix2; Matrix3x4 expected = new Matrix3x4(6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6); Assert.Equal(expected, result); }
public void HashCodeGenerationWorksCorrectly() { HashSet <int> hashCodes = new HashSet <int>(); Matrix1x4 value = new Matrix1x4(1); for (int i = 2; i <= 100; i++) { Assert.True(hashCodes.Add(value.GetHashCode()), "Unique hash code generation failure."); value *= i; } }
public void MuliplyByMatrix1x4ProducesMatrix1x4() { Matrix4x4 matrix1 = new Matrix4x4(3); Matrix1x4 matrix2 = new Matrix1x4(2); Matrix1x4 result = matrix1 * matrix2; Matrix1x4 expected = new Matrix1x4(24, 24, 24, 24); Assert.Equal(expected, result); }
public void MuliplyByMatrix1x2ProducesMatrix1x4() { Matrix2x4 matrix1 = new Matrix2x4(3); Matrix1x2 matrix2 = new Matrix1x2(2); Matrix1x4 result = matrix1 * matrix2; Matrix1x4 expected = new Matrix1x4(12, 12, 12, 12); Assert.Equal(expected, result); }
public void ColumnAccessorAreCorrect() { Matrix2x4 value; GenerateFilledMatrixWithValues(out value); Matrix1x4 column1 = value.Column1; for (int y = 0; y < value.Rows; y++) { Assert.Equal(value[0, y], column1[0, y]); } }
public void SimpleSubtractionGeneratesCorrectValues() { Matrix1x4 value1 = new Matrix1x4(100); Matrix1x4 value2 = new Matrix1x4(1); Matrix1x4 result = value1 - value2; for (int y = 0; y < Matrix1x4.RowCount; y++) { for (int x = 0; x < Matrix1x4.ColumnCount; x++) { Assert.Equal(100 - 1, result[x, y], Epsilon); } } }
public void ScalarMultiplicationIsCorrect() { GenerateFilledMatrixWithValues(out Matrix1x4 matrix1x4); for (double c = -10; c <= 10; c += 0.5) { Matrix1x4 result = matrix1x4 * c; for (int y = 0; y < matrix1x4.Rows; y++) { for (int x = 0; x < matrix1x4.Columns; x++) { Assert.Equal(matrix1x4[x, y] * c, result[x, y], Epsilon); } } } }
public void MemberGetAndSetValuesCorrectly() { Matrix1x4 matrix1x4 = new Matrix1x4(); matrix1x4.M11 = 0; matrix1x4.M12 = 1; matrix1x4.M13 = 2; matrix1x4.M14 = 3; Assert.Equal(0, matrix1x4.M11, Epsilon); Assert.Equal(1, matrix1x4.M12, Epsilon); Assert.Equal(2, matrix1x4.M13, Epsilon); Assert.Equal(3, matrix1x4.M14, Epsilon); Assert.Equal(matrix1x4[0, 0], matrix1x4.M11, Epsilon); Assert.Equal(matrix1x4[0, 1], matrix1x4.M12, Epsilon); Assert.Equal(matrix1x4[0, 2], matrix1x4.M13, Epsilon); Assert.Equal(matrix1x4[0, 3], matrix1x4.M14, Epsilon); }
public void IndexerGetAndSetValuesCorrectly() { Matrix1x4 matrix1x4 = new Matrix1x4(); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { matrix1x4[x, y] = y * matrix1x4.Columns + x; } } for (int y = 0; y < matrix1x4.Rows; y++) { for (int x = 0; x < matrix1x4.Columns; x++) { Assert.Equal(y * matrix1x4.Columns + x, matrix1x4[x, y], Epsilon); } } }
public void IndexerGetAndSetValuesCorrectly() { Matrix1x4 matrix1x4 = new Matrix1x4(); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { matrix1x4[x, y] = y * matrix1x4.Columns + x; } } for (int y = 0; y < matrix1x4.Rows; y++) { for (int x = 0; x < matrix1x4.Columns; x++) { Assert.Equal(y * matrix1x4.Columns + x, matrix1x4[x, y], Epsilon); } } }
public void AccessorThrowsWhenOutOfBounds() { Matrix1x4 matrix1x4 = new Matrix1x4(); try { matrix1x4[-1, 0] = 0; Assert.Fail("Matrix1x4[-1, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix1x4[0, -1] = 0; Assert.Fail("Matrix1x4[0, -1] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix1x4[1, 0] = 0; Assert.Fail("Matrix1x4[1, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix1x4[0, 4] = 0; Assert.Fail("Matrix1x4[0, 4] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } }
public void ConstructorValuesAreAccessibleByIndexer() { Matrix1x4 matrix1x4; matrix1x4 = new Matrix1x4(); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { Assert.Equal(0, matrix1x4[x, y], Epsilon); } } double value = 33.33; matrix1x4 = new Matrix1x4(value); for (int x = 0; x < matrix1x4.Columns; x++) { for (int y = 0; y < matrix1x4.Rows; y++) { Assert.Equal(value, matrix1x4[x, y], Epsilon); } } GenerateFilledMatrixWithValues(out matrix1x4); for (int y = 0; y < matrix1x4.Rows; y++) { for (int x = 0; x < matrix1x4.Columns; x++) { Assert.Equal(y * matrix1x4.Columns + x, matrix1x4[x, y], Epsilon); } } }
public void MuliplyByMatrix1x4ProducesMatrix1x3() { Matrix4x3 matrix1 = new Matrix4x3(3); Matrix1x4 matrix2 = new Matrix1x4(2); Matrix1x3 result = matrix1 * matrix2; Matrix1x3 expected = new Matrix1x3(24, 24, 24); Assert.Equal(expected, result); }
public void MuliplyByMatrix1x2ProducesMatrix1x4() { Matrix2x4 matrix1 = new Matrix2x4(3); Matrix1x2 matrix2 = new Matrix1x2(2); Matrix1x4 result = matrix1 * matrix2; Matrix1x4 expected = new Matrix1x4(12, 12, 12, 12); Assert.Equal(expected, result); }
public void SimpleAdditionGeneratesCorrectValues() { Matrix1x4 value1 = new Matrix1x4(1); Matrix1x4 value2 = new Matrix1x4(99); Matrix1x4 result = value1 + value2; for (int y = 0; y < Matrix1x4.RowCount; y++) { for (int x = 0; x < Matrix1x4.ColumnCount; x++) { Assert.Equal(1 + 99, result[x, y], Epsilon); } } }
public void AccessorThrowsWhenOutOfBounds() { Matrix1x4 matrix1x4 = new Matrix1x4(); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix1x4[-1, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix1x4[0, -1] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix1x4[1, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix1x4[0, 4] = 0; }); }
private void GenerateFilledMatrixWithValues(out Matrix1x4 matrix) { matrix = new Matrix1x4(0, 1, 2, 3); }
public void SimpleSubtractionGeneratesCorrectValues() { Matrix1x4 value1 = new Matrix1x4(100); Matrix1x4 value2 = new Matrix1x4(1); Matrix1x4 result = value1 - value2; for (int y = 0; y < Matrix1x4.RowCount; y++) { for (int x = 0; x < Matrix1x4.ColumnCount; x++) { Assert.AreEqual(100 - 1, result[x, y], Epsilon); } } }
public void MuliplyByMatrix4x1ProducesMatrix4x4() { Matrix1x4 matrix1 = new Matrix1x4(3); Matrix4x1 matrix2 = new Matrix4x1(2); Matrix4x4 result = matrix1 * matrix2; Matrix4x4 expected = new Matrix4x4(6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6); Assert.AreEqual(expected, result); }
public void MemberGetAndSetValuesCorrectly() { Matrix1x4 matrix1x4 = new Matrix1x4(); matrix1x4.M11 = 0; matrix1x4.M12 = 1; matrix1x4.M13 = 2; matrix1x4.M14 = 3; Assert.AreEqual(0, matrix1x4.M11, Epsilon); Assert.AreEqual(1, matrix1x4.M12, Epsilon); Assert.AreEqual(2, matrix1x4.M13, Epsilon); Assert.AreEqual(3, matrix1x4.M14, Epsilon); Assert.AreEqual(matrix1x4[0, 0], matrix1x4.M11, Epsilon); Assert.AreEqual(matrix1x4[0, 1], matrix1x4.M12, Epsilon); Assert.AreEqual(matrix1x4[0, 2], matrix1x4.M13, Epsilon); Assert.AreEqual(matrix1x4[0, 3], matrix1x4.M14, Epsilon); }
public void HashCodeGenerationWorksCorrectly() { HashSet<int> hashCodes = new HashSet<int>(); Matrix1x4 value = new Matrix1x4(1); for (int i = 2; i <= 100; i++) { if (!hashCodes.Add(value.GetHashCode())) { Assert.Fail("Unique hash code generation failure."); } value *= i; } }
public void MuliplyByMatrix1x3ProducesMatrix1x4() { Matrix3x4 matrix1 = new Matrix3x4(3); Matrix1x3 matrix2 = new Matrix1x3(2); Matrix1x4 result = matrix1 * matrix2; Matrix1x4 expected = new Matrix1x4(18, 18, 18, 18); Assert.Equal(expected, result); }
public void MuliplyByMatrix1x4ProducesMatrix1x2() { Matrix4x2 matrix1 = new Matrix4x2(3); Matrix1x4 matrix2 = new Matrix1x4(2); Matrix1x2 result = matrix1 * matrix2; Matrix1x2 expected = new Matrix1x2(24, 24); Assert.AreEqual(expected, result); }
public void EqualityOperatorWorksCorrectly() { Matrix1x4 value1 = new Matrix1x4(100); Matrix1x4 value2 = new Matrix1x4(50) * 2; Assert.AreEqual(value1, value2); Assert.IsTrue(value1 == value2, "Equality operator failed."); }