Exemple #1
0
        public void RemoveBufferWorks_SpanAndMemory(bool readOnlySpan, bool memory, bool readOnlyMemory, bool readBeforeUpdate, bool setBeforeUpdate)
        {
            SpanAndMemory duplicate = LazinatorSpanTests.GetSpanAndMemory(false);
            SpanAndMemory main      = LazinatorSpanTests.GetSpanAndMemory(false);

            main = main.CloneLazinatorTyped();
            if (readBeforeUpdate)
            {
                if (readOnlySpan)
                {
                    var read = main.MyReadOnlySpanChar;
                }
                else if (memory)
                {
                    var read = main.MyMemoryByte;
                }
                else if (readOnlyMemory)
                {
                    var read = main.MyReadOnlyMemoryChar;
                }
            }

            if (setBeforeUpdate)
            {
                if (readOnlySpan)
                {
                    main.MyReadOnlySpanChar = duplicate.MyReadOnlySpanChar;
                }
                else if (memory)
                {
                    main.MyMemoryByte = duplicate.MyMemoryByte;
                }
                else if (readOnlyMemory)
                {
                    main.MyReadOnlyMemoryChar = duplicate.MyReadOnlyMemoryChar;
                }
            }
            var original = main.LazinatorMemoryStorage;

            main.RemoveBufferInHierarchy();
            original.Dispose(); // make sure that attempting to access original will cause problems
            if (readOnlySpan)
            {
                main.MyReadOnlySpanChar.ToArray().SequenceEqual(duplicate.MyReadOnlySpanChar.ToArray()).Should().BeTrue();
            }
            else if (memory)
            {
                main.MyMemoryByte.ToArray().SequenceEqual(duplicate.MyMemoryByte.ToArray()).Should().BeTrue();
            }
            else if (readOnlyMemory)
            {
                main.MyReadOnlyMemoryChar.ToArray().SequenceEqual(duplicate.MyReadOnlyMemoryChar.ToArray()).Should().BeTrue();
            }
        }
Exemple #2
0
 public void CloneWithoutBuffer_SpanAndMemory_Empty()
 {
     VerifyCloningEquivalence(() => LazinatorSpanTests.GetSpanAndMemory(true));
 }