fixed zero-sized buffer condition check

This commit is contained in:
Timon Ringwald 2022-05-04 09:52:46 +02:00
parent e553da2c61
commit e8109737af
2 changed files with 3 additions and 3 deletions

View File

@ -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
} }
} }

View File

@ -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')
} }