fixed zero-sized buffer condition check
This commit is contained in:
parent
e553da2c61
commit
e8109737af
@ -42,7 +42,7 @@ func (b *Buffer[T]) y(y int) int {
|
|||||||
|
|
||||||
// Set sets the value at position (x,y) to c
|
// Set sets the value at position (x,y) to c
|
||||||
func (b *Buffer[T]) Set(x, y int, v T) {
|
func (b *Buffer[T]) Set(x, y int, v T) {
|
||||||
if b.width >= 0 && b.height >= 0 {
|
if b.width > 0 && b.height > 0 {
|
||||||
b.data[b.y(y)][b.x(x)] = v
|
b.data[b.y(y)][b.x(x)] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ func TestSub(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSet(t *testing.T) {
|
func TestSet(t *testing.T) {
|
||||||
b := NewBuffer(10, 10, ' ')
|
b := NewBuffer(0, 0, ' ')
|
||||||
b.Set(11, 0, 'a')
|
b.Set(0, 0, 'a')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user