assert len > 0
This commit is contained in:
@@ -6,6 +6,10 @@ type Ring struct {
|
||||
}
|
||||
|
||||
func NewRing(n int) *Ring {
|
||||
if n < 1 {
|
||||
panic("n should be greater than 0")
|
||||
}
|
||||
|
||||
return &Ring{
|
||||
elements: make([]interface{}, n),
|
||||
}
|
||||
|
||||
@@ -6,6 +6,12 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewRing(t *testing.T) {
|
||||
assert.Panics(t, func() {
|
||||
NewRing(0)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRingLess(t *testing.T) {
|
||||
ring := NewRing(5)
|
||||
for i := 0; i < 3; i++ {
|
||||
|
||||
Reference in New Issue
Block a user