Beispiel #1
0
        public void ArrayVariantHeader()
        {
            var vhArr = TypeEnumHelper <int[]> .CreateValidateTypeInfo().Header;

            Assert.AreEqual(TypeEnum.Array, vhArr.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.Int32, vhArr.TEOFS1.TypeEnum);

            var vhJArr = TypeEnumHelper <int[][][][][][][][][]> .CreateValidateTypeInfo().Header;

            Console.WriteLine(vhJArr.TEOFS);
            Console.WriteLine(vhJArr.TEOFS1);
            Console.WriteLine(vhJArr.TEOFS2);
            Console.WriteLine("----");

            Assert.AreEqual(TypeEnum.JaggedArray, vhJArr.TEOFS.TypeEnum);
            Assert.AreEqual(8, vhJArr.TEOFS2.Size);
            Assert.AreEqual(TypeEnum.Int32, vhJArr.TEOFS1.TypeEnum);

            var vhJArrKvp = TypeEnumHelper <KeyValuePair <int, int>[][][][][][][][][]> .CreateValidateTypeInfo().Header;

            Console.WriteLine(vhJArrKvp.TEOFS);
            Console.WriteLine(vhJArrKvp.TEOFS1);
            Console.WriteLine(vhJArrKvp.TEOFS2);
            Assert.AreEqual(TypeEnum.JaggedArray, vhJArrKvp.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.CompositeType, vhJArrKvp.TEOFS1.TypeEnum);
            Assert.AreEqual(8, vhJArrKvp.TEOFS2.Size);
        }
Beispiel #2
0
        public void SizeGetterBench()
        {
            var count = 2_000_000L;
            var sum   = 0L;

            for (int r = 0; r < 20; r++)
            {
                using (Benchmark.Run("Size Get", count * 255))
                {
                    for (int _ = 0; _ < count; _++)
                    {
                        for (byte b = 0; b < 255; b++)
                        {
                            sum += TypeEnumHelper.GetSize(b);
                        }
                    }
                }
            }

            Benchmark.Dump();
        }
Beispiel #3
0
        public void TupleTVariantHeader()
        {
            var vh = TypeEnumHelper <(int, int)> .DataTypeHeader;

            Console.WriteLine(vh.TEOFS);
            Console.WriteLine(vh.TEOFS1);
            Console.WriteLine(vh.TEOFS2);
            Console.WriteLine("----");
            Assert.AreEqual(TypeEnum.TupleT2, vh.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.Int32, vh.TEOFS1.TypeEnum);
            Assert.AreEqual(8, TypeEnumHelper <(int, int)> .FixedSize);

            vh = TypeEnumHelper <Tuple <int, int> > .DataTypeHeader;
            Console.WriteLine(vh.TEOFS);
            Console.WriteLine(vh.TEOFS1);
            Console.WriteLine(vh.TEOFS2);
            Console.WriteLine("----");
            Assert.AreEqual(TypeEnum.TupleT2, vh.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.Int32, vh.TEOFS1.TypeEnum);
            Assert.AreEqual(8, TypeEnumHelper <(int, int)> .FixedSize);

            vh = TypeEnumHelper <KeyValuePair <int, int> > .CreateValidateTypeInfo().Header;

            Console.WriteLine(vh.TEOFS);
            Console.WriteLine(vh.TEOFS1);
            Console.WriteLine(vh.TEOFS2);
            Console.WriteLine("----");
            Assert.AreEqual(TypeEnum.TupleT2, vh.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.Int32, vh.TEOFS1.TypeEnum);
            Assert.AreEqual(8, TypeEnumHelper <KeyValuePair <int, int> > .FixedSize);

            // same but huge types, Tuple2T with Schema
            vh = TypeEnumHelper <KeyValuePair <KeyValuePair <int, int>[][][][][][][][][], KeyValuePair <int, int>[][][][][][][][][]> > .CreateValidateTypeInfo().Header;

            Console.WriteLine(vh.TEOFS);
            Console.WriteLine(vh.TEOFS1);
            Console.WriteLine(vh.TEOFS2);
            Assert.AreEqual(TypeEnum.TupleT2, vh.TEOFS.TypeEnum);
            Assert.AreEqual(TypeEnum.CompositeType, vh.TEOFS1.TypeEnum);
        }