From e8109737afc1036fe3f3c5a6c87280bed733a167 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Wed, 4 May 2022 09:52:46 +0200 Subject: [PATCH] fixed zero-sized buffer condition check --- buffer.go | 2 +- buffer_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buffer.go b/buffer.go index eec10ed..321c7a1 100644 --- a/buffer.go +++ b/buffer.go @@ -42,7 +42,7 @@ func (b *Buffer[T]) y(y int) int { // Set sets the value at position (x,y) to c 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 } } diff --git a/buffer_test.go b/buffer_test.go index 64e55cf..a159b70 100644 --- a/buffer_test.go +++ b/buffer_test.go @@ -19,6 +19,6 @@ func TestSub(t *testing.T) { } func TestSet(t *testing.T) { - b := NewBuffer(10, 10, ' ') - b.Set(11, 0, 'a') + b := NewBuffer(0, 0, ' ') + b.Set(0, 0, 'a') }