Beispiel #1
0
        public void HashingMethods_ProducesValidHashFor_IdenticalCalculateCalls(IHasher hashFunc)
        {
            // This test seems silly, but has exposed issues with HashingMethods not being deterministic internally when run back to back (SpookyHash)
            var hash1 = hashFunc.Calculate("HashingMethods_ProducesValidHashFor_IdenticalCalculateCalls");
            var hash2 = hashFunc.Calculate("HashingMethods_ProducesValidHashFor_IdenticalCalculateCalls");

            Assert.IsTrue(hash1.Equals(hash2));
            Assert.AreEqual(TestResults[hashFunc.HashType()][(int)TestIndex.Identical], hash1.ToString());
        }
Beispiel #2
0
        public void HashingMethods_Hash128RawBytes_SameAsGeneric(IHasher hashFunc)
        {
            // Test ensures the HashingMethods.GetRawBytes() function's fast-path for Hash128 type produces the same results as generic but slower reflection based path it replaces
            Hash128 hash128 = new Hash128(0x11223344, 0x55667788, 0x99AABBCC, 0xDDEEFF00);

            Hash128Proxy hash128Proxy = new Hash128Proxy()
            {
                m_Value0 = 0x11223344, m_Value1 = 0x55667788, m_Value2 = 0x99AABBCC, m_Value3 = 0xDDEEFF00
            };

            Assert.AreEqual(hashFunc.Calculate(hash128), hashFunc.Calculate(hash128Proxy));
        }
Beispiel #3
0
        public void HashingMethods_GuidRawBytes_SameAsGeneric(IHasher hashFunc)
        {
            // Test ensures the HashingMethods.GetRawBytes() function's fast-path for GUID type produces the same results as generic but slower reflection based path it replaces
            GUID guid = new GUID("4433221188776655CCBBAA9900FFEEDD");

            GUIDProxy guidProxy = new GUIDProxy()
            {
                m_Value0 = 0x11223344, m_Value1 = 0x55667788, m_Value2 = 0x99AABBCC, m_Value3 = 0xDDEEFF00
            };

            Assert.AreEqual(hashFunc.Calculate(guid), hashFunc.Calculate(guidProxy));
        }
Beispiel #4
0
        public void HashingMethods_ProducesValidHashFor_UnicodeStrings(IHasher hashFunc)
        {
            // It might not look it at first glance, but the below 2 strings are indeed different!
            // The ASCII byte representation of both of these strings is identical, which was causing
            // hashing methods to return identical hashes as we had used ASCII for everything.
            string  str1  = "[기본]양손무기";
            string  str2  = "[기본]한손무기";
            RawHash hash1 = hashFunc.Calculate(str1);
            RawHash hash2 = hashFunc.Calculate(str2);

            Assert.AreNotEqual(str1, str2);
            Assert.AreNotEqual(hash1, hash2);
            Assert.AreEqual(TestResults[hashFunc.HashType()][(int)TestIndex.Unicode], hash1.ToString());
        }
Beispiel #5
0
        public void HashingMethods_ProducesValidHashFor_List(IHasher hashFunc)
        {
            var sourceNames = new List <string>
            {
                "basic_sprite",
                "audio",
                "prefabs",
                "shaderwithcollection",
                "multi_sprite_packed"
            };

            Assert.AreEqual(TestResults[hashFunc.HashType()][(int)TestIndex.List], hashFunc.Calculate(sourceNames).ToString());
        }
Beispiel #6
0
        public void HashingMethods_ProducesValidHashFor_Array(IHasher hashFunc)
        {
            var sourceNames = new[]
            {
                "basic_sprite",
                "audio",
                "prefabs",
                "shaderwithcollection",
                "multi_sprite_packed"
            };

            // Use (object) cast so Calculate doesn't expand the array and use params object[] objects case
            Assert.AreEqual(TestResults[hashFunc.HashType()][(int)TestIndex.Array], hashFunc.Calculate((object)sourceNames).ToString());
        }
Beispiel #7
0
        public void HashingMethods_ProducesValidHashFor_Dictionary(IHasher hashFunc)
        {
            var sourceNames = new Dictionary <string, string>
            {
                { "basic_sprite", "audio" },
                { "prefabs", "shaderwithcollection" }
            };

            Assert.AreEqual(TestResults[hashFunc.HashType()][(int)TestIndex.Dictionary], hashFunc.Calculate(sourceNames).ToString());
        }