public void CalculateHashCode() { var matrix1 = new Matrix(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); int hashCode = 0.0f.GetHashCode() + 1.0f.GetHashCode() + 2.0f.GetHashCode() + 3.0f.GetHashCode() + 4.0f.GetHashCode() + 5.0f.GetHashCode() + 6.0f.GetHashCode() + 7.0f.GetHashCode() + 8.0f.GetHashCode() + 9.0f.GetHashCode() + 10.0f.GetHashCode() + 11.0f.GetHashCode() + 12.0f.GetHashCode() + 13.0f.GetHashCode() + 14.0f.GetHashCode() + 15.0f.GetHashCode(); Assert.AreEqual(hashCode, matrix1.GetHashCode()); }
public void EqualsAndHashCode() { Matrix matrix1 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 } }); Matrix matrix2 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 } }); Matrix matrix3 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 5.0 } }); Matrix matrix4 = new Matrix(new double[][] { new double[] { 1.0, 2.0, 3.0 }, new double[] { 3.0, 4.0, 5.0 } }); Matrix matrix5 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 }, new double[] { 5.0, 6.0 } }); Assert.IsTrue(matrix1.Equals(matrix2)); Assert.IsTrue(matrix2.Equals(matrix1)); Assert.AreEqual(matrix2.GetHashCode(), matrix1.GetHashCode()); Assert.IsFalse(matrix1.Equals(matrix3)); Assert.IsFalse(matrix1.Equals(matrix4)); Assert.IsFalse(matrix1.Equals(matrix5)); Assert.IsFalse(matrix3.Equals(matrix1)); Assert.IsFalse(matrix4.Equals(matrix1)); Assert.IsFalse(matrix5.Equals(matrix1)); Assert.IsFalse(matrix1.Equals(null)); Assert.IsFalse(matrix1.Equals(42)); Assert.IsFalse(matrix1.Equals("foo")); }
public void GetHashCode_ReturnsSameValueForEquivMatrixes() { var m1 = new Matrix(new[] { new [] { 3d, 5d }, new [] { 6d, 8.7d }, }); var m2 = new Matrix(new[] { new [] { 3d, 5d }, new [] { 6d, 8.7d }, }); var hash1 = m1.GetHashCode(); var hash2 = m1.GetHashCode(); Assert.That(hash1, Is.EqualTo(hash2)); }
public static void HashCode (int times) { var value = new Matrix ( 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 1f ); int result; for (int i = 0; i < times; i++) { result = value.GetHashCode (); } }
public void op_GetHashCode_whenEmpty() { var expected = string.Empty.GetHashCode(); var actual = new Matrix<decimal>(); Assert.Equal(expected, actual.GetHashCode()); }
public void op_GetHashCode() { var expected = "-1\r\n".GetHashCode(); var actual = new Matrix<decimal>(1, 1); actual[0, 0] = decimal.MinusOne; Assert.Equal(expected, actual.GetHashCode()); }
public void GetHashCode_Not_Equal_Matrixes_Test() { Matrix a = new Matrix(2, 2, 1); Matrix b = new Matrix(2, 2, 2); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void GetHashCodeTest() { double[,] data = null; // TODO: инициализация подходящего значения Matrix target = new Matrix(data); // TODO: инициализация подходящего значения int expected = 0; // TODO: инициализация подходящего значения int actual; actual = target.GetHashCode(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Проверьте правильность этого метода теста."); }
public void GetHashCode_for_empty_matrix() { var matrix = new Matrix(); var hash = matrix.GetHashCode(); Assert.AreEqual(0, hash); }