github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/queue/ring_buffer_test.go (about) 1 package queue 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6 ) 7 8 func TestXRingBuffer_uint64(t *testing.T) { 9 rb := NewXRingBuffer[uint64](1024) 10 e := rb.LoadEntryByCursor(0) 11 e.Store(0, 1) 12 assert.Equal(t, uint64(1), e.GetValue()) 13 14 e = rb.LoadEntryByCursor(1023) 15 e.Store(1023, 100) 16 assert.Equal(t, uint64(100), e.GetValue()) 17 18 e = rb.LoadEntryByCursor(1024) 19 e.Store(1024, 1000) 20 assert.Equal(t, uint64(1000), e.GetValue()) 21 }