1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- package ringbuf
15+ package ring
1616
1717import (
1818 "io"
2828func TestBuffer (t * testing.T ) {
2929 t .Run ("push and pop" , func (t * testing.T ) {
3030 t .Run ("empty return zero" , func (t * testing.T ) {
31- b := New [int ](3 )
31+ b := NewBuffer [int ](3 )
3232 require .Equal (t , int (0 ), b .Peek ())
3333 v , ok := b .TryPop ()
3434 require .False (t , ok )
@@ -37,7 +37,7 @@ func TestBuffer(t *testing.T) {
3737 })
3838 t .Run ("populate and drain" , func (t * testing.T ) {
3939 const size = 3
40- b := New [int ](size )
40+ b := NewBuffer [int ](size )
4141 for i := 0 ; i < size ; i ++ {
4242 ok := b .TryPush (i + 1 )
4343 require .True (t , ok )
@@ -58,7 +58,7 @@ func TestBuffer(t *testing.T) {
5858 })
5959 t .Run ("populate and drain no check" , func (t * testing.T ) {
6060 const size = 3
61- b := New [int ](size )
61+ b := NewBuffer [int ](size )
6262 for i := 0 ; i < size ; i ++ {
6363 b .Push (i + 1 )
6464 require .Equal (t , i + 1 , b .Len ())
@@ -77,14 +77,14 @@ func TestBuffer(t *testing.T) {
7777 })
7878 t .Run ("write and read" , func (t * testing.T ) {
7979 t .Run ("empty return EOF" , func (t * testing.T ) {
80- b := New [int ](5 )
80+ b := NewBuffer [int ](5 )
8181 buf := make ([]int , 6 )
8282 n , err := b .Read (buf )
8383 require .Equal (t , io .EOF , err )
8484 require .Equal (t , 0 , n )
8585 })
8686 t .Run ("full" , func (t * testing.T ) {
87- b := New [int ](5 )
87+ b := NewBuffer [int ](5 )
8888 n , err := b .Write ([]int {1 , 2 , 3 , 4 , 5 })
8989 require .NoError (t , err )
9090 require .Equal (t , 5 , n )
@@ -96,7 +96,7 @@ func TestBuffer(t *testing.T) {
9696 require .Equal (t , []int {1 , 2 , 3 , 4 , 5 }, buf [:n ])
9797 })
9898 t .Run ("full via parts" , func (t * testing.T ) {
99- b := New [int ](5 )
99+ b := NewBuffer [int ](5 )
100100 n , err := b .Write ([]int {1 , 2 , 3 })
101101 require .NoError (t , err )
102102 require .Equal (t , 3 , n )
@@ -115,7 +115,7 @@ func TestBuffer(t *testing.T) {
115115 require .Equal (t , []int {1 , 2 , 3 , 4 , 5 }, buf [:5 ])
116116 })
117117 t .Run ("too large" , func (t * testing.T ) {
118- b := New [int ](5 )
118+ b := NewBuffer [int ](5 )
119119 n , err := b .Write ([]int {1 , 2 , 3 , 4 , 5 , 6 , 7 })
120120 require .NoError (t , err )
121121 require .Equal (t , 7 , n )
@@ -127,7 +127,7 @@ func TestBuffer(t *testing.T) {
127127 require .Equal (t , []int {3 , 4 , 5 , 6 , 7 }, buf [:n ])
128128 })
129129 t .Run ("too large with existing" , func (t * testing.T ) {
130- b := New [int ](5 )
130+ b := NewBuffer [int ](5 )
131131 n , err := b .Write ([]int {1 , 2 , 3 })
132132 require .NoError (t , err )
133133 require .Equal (t , 3 , n )
@@ -142,7 +142,7 @@ func TestBuffer(t *testing.T) {
142142 require .Equal (t , []int {3 , 4 , 5 , 6 , 7 }, buf [:n ])
143143 })
144144 t .Run ("interleaved" , func (t * testing.T ) {
145- b := New [int ](6 )
145+ b := NewBuffer [int ](6 )
146146 buf := make ([]int , 6 )
147147
148148 n , err := b .Write ([]int {1 , 2 , 3 , 4 })
@@ -162,7 +162,7 @@ func TestBuffer(t *testing.T) {
162162 require .Equal (t , []int {4 , 5 , 6 , 10 , 11 , 12 }, buf [:n ])
163163 })
164164 t .Run ("interleaved drop" , func (t * testing.T ) {
165- b := New [int ](6 )
165+ b := NewBuffer [int ](6 )
166166 buf := make ([]int , 6 )
167167
168168 n , err := b .Write ([]int {1 , 2 , 3 , 4 })
0 commit comments