Пример #1
0
            public void FromJson_StructWithInt32Property_DoesNotAllocate()
            {
                var json = "{\"Int32Property\": 42}";

                GCAllocTest.Method(() => { JsonSerialization.FromJson <StructWithInt32Property>(json); })
                .ExpectedCount(0)
                .Warmup()
                .Run();
            }
Пример #2
0
            public void ToJson_StructWithInt32Property_DoesNotAllocate()
            {
                var container = new StructWithInt32Property();

                GCAllocTest.Method(() =>
                {
                    using (var writer = new JsonStringBuffer(16, Allocator.Temp))
                    {
                        JsonSerialization.ToJson(writer, container);
                    }
                })
                .ExpectedCount(0)
                .Warmup()
                .Run();
            }
Пример #3
0
            public void ToBinary_StructWithInt32Property_DoesNotAllocate()
            {
                var container = new StructWithInt32Property();

                GCAllocTest.Method(() =>
                {
                    using (var stream = new UnsafeAppendBuffer(16, 8, Allocator.Temp))
                    {
                        BinarySerialization.ToBinary(&stream, container);
                    }
                })
                .ExpectedCount(0)
                .Warmup()
                .Run();
            }
Пример #4
0
            public void FromBinary_StructWithInt32Property_DoesNotAllocate()
            {
                var container = new StructWithInt32Property();

                using (var writer = new UnsafeAppendBuffer(16, 8, Allocator.Temp))
                {
                    var writerPtr = &writer;

                    BinarySerialization.ToBinary(writerPtr, container);

                    GCAllocTest.Method(() =>
                    {
                        var reader    = writerPtr->AsReader();
                        var readerPtr = &reader;

                        BinarySerialization.FromBinary <StructWithInt32Property>(readerPtr);
                    })
                    .ExpectedCount(0)
                    .Warmup()
                    .Run();
                }
            }