<commit_before>package falcore

import (
/*	"io"*/
	"bytes"
	"testing"
)

func TestBufferPool(t *testing.T){
	pool := newBufferPool(10, 1024)
	
	text := []byte("Hello World")
	
	// get one
	bpe := pool.take(bytes.NewBuffer(text))
	// read all
	out := make([]byte, 1024)
	l, _ := bpe.buf.Read(out)
	if bytes.Compare(out[0:l], text) != 0 {
		t.Errorf("Read invalid data: %v", out)
	}
	if l != len(text) {
		t.Errorf("Expected length %v got %v", len(text), l)
	}
	pool.give(bpe)
	
	
	// get one
	bpe = pool.take(bytes.NewBuffer(text))
	// read all
	out = make([]byte, 1024)
	l, _ = bpe.buf.Read(out)
	if bytes.Compare(out[0:l], text) != 0 {
		t.Errorf("Read invalid data: %v", out)
	}
	if l != len(text) {
		t.Errorf("Expected length %v got %v", len(text), l)
	}
	pool.give(bpe)
	
}<commit_msg>test with partially read buffers as well<commit_after>package falcore

import (
/*	"io"*/
	"bytes"
	"testing"
)

func TestBufferPool(t *testing.T){
	pool := newBufferPool(10, 1024)
	
	text := []byte("Hello World")
	
	// get one
	bpe := pool.take(bytes.NewBuffer(text))
	// read all
	out := make([]byte, 1024)
	l, _ := bpe.buf.Read(out)
	if bytes.Compare(out[0:l], text) != 0 {
		t.Errorf("Read invalid data: %v", out)
	}
	if l != len(text) {
		t.Errorf("Expected length %v got %v", len(text), l)
	}
	pool.give(bpe)
	
	
	// get one
	bpe = pool.take(bytes.NewBuffer(text))
	// read all
	out = make([]byte, 1024)
	l, _ = bpe.buf.Read(out)
	if bytes.Compare(out[0:l], text) != 0 {
		t.Errorf("Read invalid data: %v", out)
	}
	if l != len(text) {
		t.Errorf("Expected length %v got %v", len(text), l)
	}
	pool.give(bpe)

	// get one
	bpe = pool.take(bytes.NewBuffer(text))
	// read 1 byte
	out = make([]byte, 1)
	bpe.buf.Read(out)
	pool.give(bpe)

	// get one
	bpe = pool.take(bytes.NewBuffer(text))
	// read all
	out = make([]byte, 1024)
	l, _ = bpe.buf.Read(out)
	if bytes.Compare(out[0:l], text) != 0 {
		t.Errorf("Read invalid data: %v", out)
	}
	if l != len(text) {
		t.Errorf("Expected length %v got %v", len(text), l)
	}
	pool.give(bpe)

	
}
{'fraction_non_alphanumeric': 0.20058997050147492, 'fraction_numerical': 0.021632251720747297, 'mean_word_length': 3.3857758620689653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7418188', 'n_tokens_mistral': 927, 'n_tokens_neox': 853, 'n_words': 203}