Example #1
0
 public void TooManyFieldsInTuple()
 {
     Assert.Throws <TooManyFieldsInTupleException>(() =>
     {
         byte *ptype = TypeCodec.EncodeType <BigStruct>();
     });
 }
Example #2
0
        public void Decode_Fine()
        {
            var ptype = TypeCodec.EncodeType <int>();

            Assert.Equal(typeof(int), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <uint>();
            Assert.Equal(typeof(uint), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <string>();
            Assert.Equal(typeof(string), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <double>();
            Assert.Equal(typeof(double), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <List <int> >();
            Assert.Equal(typeof(List <int>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <List <long> >();
            Assert.Equal(typeof(List <long>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_1>();
            Assert.Equal(typeof(ValueTuple <int, double>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_2>();
            Assert.Equal(typeof(ValueTuple <string, string, string, string>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_3>();
            Assert.Equal(typeof(ValueTuple <
                                    ValueTuple <string, string, string, string>,
                                    string,
                                    List <ValueTuple <int, double> > >), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_1>();
            Assert.Equal(typeof(ValueTuple <int, double>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_2>();
            Assert.Equal(typeof(ValueTuple <string, string, string, string>), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_3>();
            Assert.Equal(typeof(ValueTuple <
                                    ValueTuple <string, string, string, string>,
                                    string,
                                    List <ValueTuple <int, double> > >), TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);
        }
Example #3
0
        //[Fact]
        //Ignored: coreclr test framework problem
        public void ManyFieldsInTuple()
        {
            byte *ptype = TypeCodec.EncodeType <BigStruct2>();
            Type  t     = typeof(
                ValueTuple <int, int, int, int, int, int, int,
                            ValueTuple <int, int, int, int, int, int, int,
                                        ValueTuple <int, int, int, int, int, int, int,
                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                            ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                                        ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                                                    ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                ValueTuple <int, int, int, int, int, int, int,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ValueTuple <int, int, int> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >);

            Assert.Equal(t, TypeCodec.DecodeType(ptype));
            TypeCodec.FreeTypeCode(ptype);
        }
Example #4
0
        public void Allocate_Deallocate_Fine()
        {
            var ptype = TypeCodec.EncodeType <int>();

            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <uint>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <string>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <double>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <List <int> >();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <List <long> >();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_1>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_2>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestStruct_3>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_1>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_2>();
            TypeCodec.FreeTypeCode(ptype);

            ptype = TypeCodec.EncodeType <TestClass_3>();
            TypeCodec.FreeTypeCode(ptype);
        }