public void EqualsTest() { HammingInteger curr = new HammingInteger(); HammingInteger other = new HammingInteger(); Assert.IsFalse(curr.Equals(null)); // null test Assert.IsFalse(curr.Equals("stringObject")); // different object test Assert.IsTrue(curr.Equals(other)); // empty test // test different integer tests byte test = 10; Int16 diffInt = 10; curr.EncodeToHammingCode(test); other.EncodeToHammingCode(diffInt); Assert.IsFalse(curr.Equals(other)); // test same integer type different integer value test = 10; byte test2 = 9; curr.EncodeToHammingCode(test); other.EncodeToHammingCode(test2); Assert.IsFalse(curr.Equals(other)); // test Int8 test = 10; test2 = 10; curr.EncodeToHammingCode(test); other.EncodeToHammingCode(test2); Assert.IsTrue(curr.Equals(other)); // test Int16 Int16 testInt16 = 100; Int16 test2Int16 = 100; curr.EncodeToHammingCode(testInt16); other.EncodeToHammingCode(test2Int16); Assert.IsTrue(curr.Equals(other)); // test Int32 int testInt32 = 1000; int test2Int32 = 1000; curr.EncodeToHammingCode(testInt32); other.EncodeToHammingCode(test2Int32); Assert.IsTrue(curr.Equals(other)); // test Int64 Int64 testInt64 = 10000; Int64 test2Int64 = 10000; curr.EncodeToHammingCode(testInt64); other.EncodeToHammingCode(test2Int64); Assert.IsTrue(curr.Equals(other)); // test bytes array byte[] testArray = { 1, 10 }; byte[] testArray2 = { 1, 10 }; curr.EncodeToHammingCode(testArray); other.EncodeToHammingCode(testArray2); Assert.IsTrue(curr.Equals(other)); }
public void CloneTest() { // None test HammingInteger hi = new HammingInteger(); HammingInteger clone = hi.Clone(); Assert.AreEqual(hi, clone); // Int8 byte testByte = 100; hi = new HammingInteger(testByte); clone = hi.Clone(); Assert.AreEqual(hi, clone); // Int16 Int16 testInt16 = 100; hi = new HammingInteger(testInt16); clone = hi.Clone(); Assert.AreEqual(hi, clone); // Int32 Int32 testInt32 = 100; hi = new HammingInteger(testInt32); clone = hi.Clone(); Assert.AreEqual(hi, clone); // Int64 Int64 testInt64 = 100; hi = new HammingInteger(testInt64); clone = hi.Clone(); Assert.AreEqual(hi, clone); // Byte Array byte[] byteArray = { 1, 10, 100 }; hi = new HammingInteger(byteArray); clone = hi.Clone(); Assert.AreEqual(hi, clone); // Test that clone isn't a swallow copy Int16 lastTest = 10; clone.EncodeToHammingCode(lastTest); Assert.AreNotEqual(hi, clone); }