Beispiel #1
0
 public unsafe void SetLengthToFirstNullEmptyBuffer()
 {
     using (var buffer = new StringBuffer())
     {
         buffer.SetLengthToFirstNull();
         Assert.Equal((ulong)0, buffer.Length);
     }
 }
Beispiel #2
0
        public unsafe void SetLengthToFirstNullTests(string content, ulong startLength, ulong endLength)
        {
            using (var buffer = new StringBuffer(content))
            {
                // With existing content
                Assert.Equal(startLength, buffer.Length);
                buffer.SetLengthToFirstNull();
                Assert.Equal(endLength, buffer.Length);

                // Clear the buffer & manually copy in
                buffer.Length = 0;
                fixed (char* contentPointer = content)
                {
                    Buffer.MemoryCopy(contentPointer, buffer.CharPointer, (long)buffer.CharCapacity * 2, content.Length * sizeof(char));
                }

                Assert.Equal((ulong)0, buffer.Length);
                buffer.SetLengthToFirstNull();
                Assert.Equal(endLength, buffer.Length);
            }
        }
Beispiel #3
0
 public unsafe void SetLengthToFirstNullNoNull()
 {
     using (var buffer = new StringBuffer("A"))
     {
         // Wipe out the last null
         buffer.CharPointer[buffer.Length] = 'B';
         buffer.SetLengthToFirstNull();
         Assert.Equal((ulong)1, buffer.Length);
     }
 }