<commit_before>package PublishReplay

import (
	"testing"
	"time"
	// "time"

	"github.com/stretchr/testify/assert"
)

// Basic example with the maximum buffer capacity of approx. 32000 items where
// items are retained forever.
func TestReplayBasic(t *testing.T) {
	ch := make(chan int, 5)
	for i := 0; i < 5; i++ {
		ch <- i
	}
	close(ch)
	source := FromChanInt(ch).PublishReplay(0, 0)
	source.Connect()

	expected := []int{0, 1, 2, 3, 4}

	result, err := source.ToSlice()
	assert.NoError(t, err)
	assert.Equal(t, expected, result)

	result, err = source.ToSlice()
	assert.NoError(t, err)
	assert.Equal(t, expected, result)
}

// Example that shows using a buffer that retains only the latest 2 values.
func TestReplayWithSize(t *testing.T) {
	ch := make(chan int, 5)<commit_msg>Fix for PublishReplay test.<commit_after>package PublishReplay

import (
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

// Basic example with the maximum buffer capacity of approx. 32000 items where
// items are retained forever.
func TestReplayBasic(t *testing.T) {
	ch := make(chan int, 5)
	for i := 0; i < 5; i++ {
		ch <- i
	}
	close(ch)
	source := FromChanInt(ch).PublishReplay(0, 0)
	source.Connect()

	expected := []int{0, 1, 2, 3, 4}

	result, err := source.ToSlice()
	assert.NoError(t, err)
	assert.Equal(t, expected, result)

	result, err = source.ToSlice()
	assert.NoError(t, err)
	assert.Equal(t, expected, result)
}

// Example that shows using a buffer that retains only the latest 2 values and
// the use of AutoConnect to declaratively call the Connect method.
func TestReplayWithSize(t *testing.T) {
	ch := make(chan int, 5)
{'fraction_non_alphanumeric': 0.1363080684596577, 'fraction_numerical': 0.02078239608801956, 'mean_word_length': 3.9908536585365852, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4650374', 'n_tokens_mistral': 621, 'n_tokens_neox': 582, 'n_words': 182}