public unsafe void SetLengthToFirstNullEmptyBuffer() { using (var buffer = new StringBuffer()) { buffer.SetLengthToFirstNull(); Assert.Equal((ulong)0, buffer.Length); } }
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); } }
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); } }