public void EQMapHashTest2() { int length = 20; // create equality map EqualityMap map = new EqualityMap(); for (int i = 0; i < length; ++i) { map.Add( new PrettyName("chi", i), new DoubleIndex(i, 0) ); map.Add( new PrettyName("chi", i), new DoubleIndex(length + i, 0) ); } byte[] hash1 = map.Hash(DefaultHashFunction); byte[] hash2 = map.Hash(DefaultHashFunction); StaticHelperClass.AssertArraysAreEqual <byte>(hash1, hash2, "same map hash."); // create parallel map in different order EqualityMap map2 = new EqualityMap(); for (int i = 0; i < length; ++i) { map2.Add( new PrettyName("chi", i), new DoubleIndex(length + i, 0) ); } for (int i = 0; i < length; ++i) { map2.Add( new PrettyName("chi", i), new DoubleIndex(i, 0) ); } byte[] hash3 = map2.Hash(DefaultHashFunction); byte[] hash4 = map2.Hash(DefaultHashFunction); StaticHelperClass.AssertArraysAreEqual <byte>(hash3, hash4, "map2 hash."); StaticHelperClass.AssertArraysAreEqual <byte>(hash1, hash3, "hash1 vs hash 3."); }
public void EQMapHashTest() { EqualityMap map1 = new EqualityMap(); map1.Add(new PrettyName("alpha", 0), new DoubleIndex(0, 0)); map1.Add(new PrettyName("alpha", 2), new DoubleIndex(1, 1)); byte[] hash1 = map1.Hash(CryptoParameters.DefaultHashFunctionName); byte[] hash2 = map1.Hash(CryptoParameters.DefaultHashFunctionName); StaticHelperClass.AssertArraysAreEqual <byte>(hash1, hash2, "hash1 vs hash2 of same map."); EqualityMap map2 = new EqualityMap(); map2.Add(new PrettyName("alpha", 2), new DoubleIndex(1, 1)); map2.Add(new PrettyName("alpha", 0), new DoubleIndex(0, 0)); byte[] hash3 = map2.Hash(CryptoParameters.DefaultHashFunctionName); byte[] hash4 = map2.Hash(CryptoParameters.DefaultHashFunctionName); StaticHelperClass.AssertArraysAreEqual <byte>(hash3, hash4, "hash3 vs hash4 of same map."); StaticHelperClass.AssertArraysAreEqual <byte>(hash1, hash3, "hash1 vs hash3."); }