You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: buffer_test.go
    path of file: ./repos/memguard/core
    
    the code of the file until where you have to start completion: package core

import (
	"bytes"
	"testing"
	"unsafe"
)

func TestNewBuffer(t *testing.T) {
	// Check the error case with zero length.
	b, err := NewBuffer(0)
	if err != ErrNullBuffer {
		t.Error("expected ErrNullBuffer; got", err)
	}
	if b != nil {
		t.Error("expected nil buffer; got", b)
	}

	// Check the error case with negative length.
	b, err = NewBuffer(-1)
	if err != ErrNullBuffer {
		t.Error("expected ErrNullBuffer; got", err)
	}
	if b != nil {
		t.Error("expected nil buffer; got", b)
	}

	// Test normal execution.
	b, err = NewBuffer(32)
	if err != nil {
		t.Error("expected nil err; got", err)
	}
	if !b.alive {
		t.Error("did not expect destroyed buffer")
	}
	if len(b.Data()) != 32 || cap(b.Data()) != 32 {
		t.Errorf("buffer has invalid length (%d) or capacity (%d)", len(b.Data()), cap(b.Data()))
	}
	if !b.mutable {
		t.Error("buffer is not marked mutable")
	}
	if len(b.memory) != roundToPageSize(32)+(2*pageSize) {
		t.Error("allocated incorrect length of memory")
	}
	if !bytes.Equal(b.Data(), make([]byte, 32)) {
		t.Error("container is not zero-filled")
	}

	// Check if the buffer was added to the buffers list.
	if !buffers.exists(b) {
		t.Error("buffer not in buffers list")
	}

	// Destroy the buffer.
	b.De
    
func TestBufferList(t *testing.T) {
	// Create a new BufferList for testing with.
	l := new(bufferList)

	// Create some example buffers to test with.
	a := new(Buffer)
	b := new(Buffer)

	// Check what Exists is saying.
	if l.exists(a) || l.exists(b) {
		t.Error("list is empty yet contains buffers?!")
	}

	// Add our two buffers to the list.
	l.add(a)
	if len(l.list) != 1 || l.list[0] != a {
		t.Error("buffer was not added correctly")
	}
	l.add(b)
	if len(l.list) != 2 || l.list[1] != b {
		t.Error("buffer was not added correctly")
	}

	// Now check that they exist.
	if !l.exists(a) || !l.exists(b) {
		t.Error("expected buffers to be in list")
	}

	// Remove the buffers from the list.
	l.remove(a)
	if len(l.list) != 1 || l.list[0] != b {
		t.Error("buffer was not removed correctly")
	}
	l.remove(b)
	if len(l.list) != 0 {
		t.Error("item was not removed correctly")
	}

	// Check what exists is saying now.
	if l.exists(a) || l.exists(b) {
		t.Error("list is empty yet contains buffers?!")
	}

	// Add the buffers again to test Empty.
	l.add(a)
	l.add(b)
	bufs := l.flush()
	if l.list != nil {
		t.Error("list was not nullified")
	}
	if len(bufs) != 2 || bufs[0] != a || bufs[1] != b {
		t.Error("buffers dump incorrect")
	}

	// Try appending again.
	l.add(a)
	if !l.exists(a) || l.exists(b) {
		t.Error("list is in invalid state")
	}
	l.remove(a)
}