Esempio n. 1
0
        public void EqualsPadding()
        {
            var typeInfo = FastEquality.CreateTypeInfo(typeof(EndPadding));

            Assert.IsTrue(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(1, 2), typeInfo));
            Assert.IsFalse(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(1, 3), typeInfo));
            Assert.IsFalse(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(4, 2), typeInfo));
        }
Esempio n. 2
0
        public void EqualsPadding()
        {
            var layout = FastEquality.CreateLayout(typeof(EndPadding));

            Assert.IsTrue(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(1, 2), layout));
            Assert.IsFalse(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(1, 3), layout));
            Assert.IsFalse(FastEquality.Equals(new EndPadding(1, 2), new EndPadding(4, 2), layout));
        }
Esempio n. 3
0
        public void EqualsInt4()
        {
            var layout = FastEquality.CreateLayout(typeof(int4));

            Assert.IsTrue(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(1, 2, 3, 4), layout));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(1, 2, 3, 5), layout));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(0, 2, 3, 4), layout));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(5, 6, 7, 8), layout));
        }
Esempio n. 4
0
        public void EqualsInt4()
        {
            var typeInfo = FastEquality.CreateTypeInfo(typeof(int4));

            Assert.IsTrue(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(1, 2, 3, 4), typeInfo));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(1, 2, 3, 5), typeInfo));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(0, 2, 3, 4), typeInfo));
            Assert.IsFalse(FastEquality.Equals(new int4(1, 2, 3, 4), new int4(5, 6, 7, 8), typeInfo));
        }
Esempio n. 5
0
        public void CorrectEqualsIsUsed()
        {
            var typeInfo = FastEquality.CreateTypeInfo(typeof(DoubleEquals));
            var a        = new DoubleEquals {
            };
            var b        = new DoubleEquals {
            };
            bool iseq    = FastEquality.Equals <DoubleEquals>(a, b, typeInfo);

            Assert.IsTrue(iseq);
        }
Esempio n. 6
0
        public void EqualsEnum()
        {
            var typeInfo = FastEquality.CreateTypeInfo(typeof(EnumStruct));

            var a = new EnumStruct {
                nephew = Nephew.Huey
            };
            var b = new EnumStruct {
                nephew = Nephew.Dewey
            };

            Assert.IsTrue(FastEquality.Equals(a, a, typeInfo));
            Assert.IsFalse(FastEquality.Equals(a, b, typeInfo));
        }
        public unsafe void EqualsFixedArray()
        {
            var typeInfo = FastEquality.CreateTypeInfo(typeof(FixedArrayStruct));

            var a = new FixedArrayStruct();

            a.array[0] = 123;
            a.array[1] = 234;
            a.array[2] = 345;

            var b = a;

            Assert.IsTrue(FastEquality.Equals(a, b, typeInfo));

            b.array[1] = 456;

            Assert.IsFalse(FastEquality.Equals(a, b, typeInfo));
        }
        public void FastEqualityWorksFromBurst()
        {
            TypeManager.Initialize();

            Entity a1 = new Entity()
            {
                Index = 1, Version = 2
            };
            Entity a2 = a1;
            Entity b  = new Entity()
            {
                Index = 2, Version = 1
            };
            var monoA1EqualsA2  = FastEquality.Equals(a1, a2);
            var monoA1EqualsB   = FastEquality.Equals(a1, b);
            var burstA1EqualsA2 = BurstedTestFuncCallingEquals.Invoke(ref a1, ref a2);
            var burstA1EqualsB  = BurstedTestFuncCallingEquals.Invoke(ref a1, ref b);

            Assert.IsTrue(monoA1EqualsA2);
            Assert.IsTrue(burstA1EqualsA2);
            Assert.IsFalse(monoA1EqualsB);
            Assert.IsFalse(burstA1EqualsB);

            var monoA1GetHashCode  = FastEquality.GetHashCode(a1);
            var monoA2GetHashCode  = FastEquality.GetHashCode(a2);
            var monoBGetHashCode   = FastEquality.GetHashCode(b);
            var burstA1GetHashCode = BurstedTestFuncCallingGetHashCode.Invoke(ref a1);
            var burstA2GetHashCode = BurstedTestFuncCallingGetHashCode.Invoke(ref a2);
            var burstBGetHashCode  = BurstedTestFuncCallingGetHashCode.Invoke(ref b);

            Assert.AreEqual(monoA1GetHashCode, burstA1GetHashCode);
            Assert.AreEqual(monoA2GetHashCode, burstA2GetHashCode);
            Assert.AreEqual(monoBGetHashCode, burstBGetHashCode);
            Assert.AreEqual(monoA1GetHashCode, monoA2GetHashCode);
            Assert.AreNotEqual(monoA1GetHashCode, monoBGetHashCode);
        }
 private static unsafe bool _mono_to_burst_CallEquals(ref Entity a, ref Entity b)
 {
     return(FastEquality.Equals(a, b));
 }