public void Test_hashCode_Ljava_lang_Object() { int listHashCode; int arrayHashCode; Object[] objectArr = { new int?(1), new float?(10e-12f), null }; List <object> listOfObject = new List <object>(); for (int i = 0; i < objectArr.Length; i++) { listOfObject.Add(objectArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfObject); arrayHashCode = Arrays.GetHashCode(objectArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LD() { int listHashCode; int arrayHashCode; double[] doubleArr = { 0.134945657, 0.0038754, 11e-150, -30e-300, 10e-4 }; List <double> listOfDouble = new List <double>(); for (int i = 0; i < doubleArr.Length; i++) { listOfDouble.Add(doubleArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfDouble); arrayHashCode = Arrays.GetHashCode(doubleArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LS() { int listHashCode; int arrayHashCode; short[] shortArr = { 35, 13, 45, 2, 91 }; List <short> listOfShort = new List <short>(); for (int i = 0; i < shortArr.Length; i++) { listOfShort.Add(shortArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfShort); arrayHashCode = Arrays.GetHashCode(shortArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LC() { int listHashCode; int arrayHashCode; char[] charArr = { 'a', 'g', 'x', 'c', 'm' }; List <char> listOfCharacter = new List <char>(); for (int i = 0; i < charArr.Length; i++) { listOfCharacter.Add(charArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfCharacter); arrayHashCode = Arrays.GetHashCode(charArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LB() { int listHashCode; int arrayHashCode; byte[] byteArr = { 5, 9, 7, 6, 17 }; List <byte> listOfByte = new List <byte>(); for (int i = 0; i < byteArr.Length; i++) { listOfByte.Add(byteArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfByte); arrayHashCode = Arrays.GetHashCode(byteArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LZ() { int listHashCode; int arrayHashCode; bool[] boolArr = { true, false, false, true, false }; List <bool> listOfBoolean = new List <bool>(); for (int i = 0; i < boolArr.Length; i++) { listOfBoolean.Add(boolArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfBoolean); arrayHashCode = Arrays.GetHashCode(boolArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LJ() { int listHashCode; int arrayHashCode; long[] longArr = { 67890234512L, 97587236923425L, 257421912912L, 6754268100L, 5 }; List <long> listOfLong = new List <long>(); for (int i = 0; i < longArr.Length; i++) { listOfLong.Add(longArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfLong); arrayHashCode = Arrays.GetHashCode(longArr); assertEquals(listHashCode, arrayHashCode); }
public void Test_hashCode_LF() { int listHashCode; int arrayHashCode; float[] floatArr = { 0.13497f, 0.268934f, 12e-5f, -3e+2f, 10e-4f }; List <float> listOfFloat = new List <float>(); for (int i = 0; i < floatArr.Length; i++) { listOfFloat.Add(floatArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfFloat); arrayHashCode = Arrays.GetHashCode(floatArr); assertEquals(listHashCode, arrayHashCode); float[] floatArr2 = { 0.13497f, 0.268934f, 12e-5f, -3e+2f, 10e-4f }; assertEquals(Arrays.GetHashCode(floatArr2), Arrays.GetHashCode(floatArr)); }
public void Test_hashCode_LI() { int listHashCode; int arrayHashCode; int[] intArr = { 10, 5, 134, 7, 19 }; List <int> listOfInteger = new List <int>(); for (int i = 0; i < intArr.Length; i++) { listOfInteger.Add(intArr[i]); } listHashCode = CollectionUtil.GetHashCode(listOfInteger); arrayHashCode = Arrays.GetHashCode(intArr); assertEquals(listHashCode, arrayHashCode); int[] intArr2 = { 10, 5, 134, 7, 19 }; assertEquals(Arrays.GetHashCode(intArr2), Arrays.GetHashCode(intArr)); }
public void TestEqualityDictionary() { var control = new SCG.Dictionary <string, IDictionary <HashMap <long, double>, string> > { { "a", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 123, 9.87 }, { 80, 88 } }, "qwerty" } } }, { "z", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 456, 9.86 }, { 81, 88 } }, "hexagon" } } }, { "r", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 789, 9.85 }, { 82, 88 } }, "parasite" } } }, { "t", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 101, 9.84 }, { 83, 88 } }, "octopus" } } }, }; var equal = new SCG.Dictionary <string, IDictionary <HashMap <long, double>, string> > { { "a", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 123, 9.87 }, { 80, 88 } }, "qwerty" } } }, { "z", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 456, 9.86 }, { 81, 88 } }, "hexagon" } } }, { "r", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 789, 9.85 }, { 82, 88 } }, "parasite" } } }, { "t", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 101, 9.84 }, { 83, 88 } }, "octopus" } } }, }; var equalDifferentType = new HashMap <string, IDictionary <HashMap <long, double>, string> > { { "a", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 123, 9.87 }, { 80, 88 } }, "qwerty" } } }, { "z", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 456, 9.86 }, { 81, 88 } }, "hexagon" } } }, { "r", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 789, 9.85 }, { 82, 88 } }, "parasite" } } }, { "t", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 101, 9.84 }, { 83, 88 } }, "octopus" } } }, }; var equalDifferentOrder = new SCG.Dictionary <string, IDictionary <HashMap <long, double>, string> > { { "r", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 789, 9.85 }, { 82, 88 } }, "parasite" } } }, { "t", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 101, 9.84 }, { 83, 88 } }, "octopus" } } }, { "a", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 123, 9.87 }, { 80, 88 } }, "qwerty" } } }, { "z", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 456, 9.86 }, { 81, 88 } }, "hexagon" } } }, }; var level1EqualLevel2EqualLevel3Unequal = new SCG.Dictionary <string, IDictionary <HashMap <long, double>, string> > { { "a", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 123, 9.87 }, { 80, 88.1 } }, "qwerty" } } }, { "z", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 456, 9.86 }, { 81, 88 } }, "hexagon" } } }, { "r", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 789, 9.85 }, { 82, 88 } }, "parasite" } } }, { "t", new SCG.Dictionary <HashMap <long, double>, string> { { new HashMap <long, double> { { 101, 9.84 }, { 83, 88 } }, "octopus" } } }, }; Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(control)); Assert.IsTrue(CollectionUtil.Equals(control, control)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equal)); Assert.IsTrue(CollectionUtil.Equals(control, equal)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentType)); Assert.IsTrue(CollectionUtil.Equals(control, equalDifferentType)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentOrder)); Assert.IsTrue(CollectionUtil.Equals(control, equalDifferentOrder)); Assert.AreNotEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(level1EqualLevel2EqualLevel3Unequal)); Assert.IsFalse(CollectionUtil.Equals(control, level1EqualLevel2EqualLevel3Unequal)); }
public void TestEqualitySet() { var control = new SCG.HashSet <IDictionary <string, string> > { new SCG.Dictionary <string, string> { { "1", "one" }, { "2", "two" }, { "3", "three" } }, new SCG.Dictionary <string, string> { { "4", "four" }, { "5", "five" }, { "6", "six" } }, new SCG.Dictionary <string, string> { { "7", "seven" }, { "8", "eight" }, { "9", "nine" } }, }; var equal = new SCG.HashSet <IDictionary <string, string> > { new SCG.Dictionary <string, string> { { "1", "one" }, { "2", "two" }, { "3", "three" } }, new SCG.Dictionary <string, string> { { "4", "four" }, { "5", "five" }, { "6", "six" } }, new SCG.Dictionary <string, string> { { "7", "seven" }, { "8", "eight" }, { "9", "nine" } }, }; var equalDifferentType = new MockHashSet <IDictionary <string, string> > { new SCG.Dictionary <string, string> { { "1", "one" }, { "2", "two" }, { "3", "three" } }, new SCG.Dictionary <string, string> { { "4", "four" }, { "5", "five" }, { "6", "six" } }, new SCG.Dictionary <string, string> { { "7", "seven" }, { "8", "eight" }, { "9", "nine" } }, }; var equalDifferentOrder = new SCG.HashSet <IDictionary <string, string> > { new SCG.Dictionary <string, string> { { "7", "seven" }, { "8", "eight" }, { "9", "nine" } }, new SCG.Dictionary <string, string> { { "1", "one" }, { "2", "two" }, { "3", "three" } }, new SCG.Dictionary <string, string> { { "4", "four" }, { "5", "five" }, { "6", "six" } }, }; var level1EqualLevel2Unequal = new SCG.HashSet <IDictionary <string, string> > { new SCG.Dictionary <string, string> { { "1", "one" }, { "2", "two" }, { "3", "three" } }, new SCG.Dictionary <string, string> { { "4", "four" }, { "5", "five" }, { "6", "six" } }, new SCG.Dictionary <string, string> { { "7", "seven" }, { "8", "eight" }, { "9", "nine99" } }, }; Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(control)); Assert.IsTrue(CollectionUtil.Equals(control, control)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equal)); Assert.IsTrue(CollectionUtil.Equals(control, equal)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentType)); Assert.IsTrue(CollectionUtil.Equals(control, equalDifferentType)); // Sets are not order-sensitive Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentOrder)); Assert.IsTrue(CollectionUtil.Equals(control, equalDifferentOrder)); Assert.AreNotEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(level1EqualLevel2Unequal)); Assert.IsFalse(CollectionUtil.Equals(control, level1EqualLevel2Unequal)); }
public void TestEqualityListSimple() { var control = new SCG.List <IList <string> > { new SCG.List <string> { "one", "two", "three" }, new SCG.List <string> { "four", "five", "six" }, new SCG.List <string> { "seven", "eight", "nine" }, }; var equal = new SCG.List <IList <string> > { new SCG.List <string> { "one", "two", "three" }, new SCG.List <string> { "four", "five", "six" }, new SCG.List <string> { "seven", "eight", "nine" }, }; var equalDifferentType = new IList <string>[] { new SCG.List <string> { "one", "two", "three" }, new SCG.List <string> { "four", "five", "six" }, new SCG.List <string> { "seven", "eight", "nine" }, }; var equalDifferentOrder = new SCG.List <IList <string> > { new SCG.List <string> { "four", "five", "six" }, new SCG.List <string> { "seven", "eight", "nine" }, new SCG.List <string> { "one", "two", "three" }, }; var level1EqualLevel2Unequal = new SCG.List <IList <string> > { new SCG.List <string> { "one", "two", "three" }, new SCG.List <string> { "four", "five", "six" }, new SCG.List <string> { "seven", "eight", "nine-nine" }, }; Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(control)); Assert.IsTrue(CollectionUtil.Equals(control, control)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equal)); Assert.IsTrue(CollectionUtil.Equals(control, equal)); Assert.AreEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentType)); Assert.IsTrue(CollectionUtil.Equals(control, equalDifferentType)); // Lists and arrays are order - sensitive Assert.AreNotEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(equalDifferentOrder)); Assert.IsFalse(CollectionUtil.Equals(control, equalDifferentOrder)); Assert.AreNotEqual(CollectionUtil.GetHashCode(control), CollectionUtil.GetHashCode(level1EqualLevel2Unequal)); Assert.IsFalse(CollectionUtil.Equals(control, level1EqualLevel2Unequal)); }