diff --git a/npq/lib_test.go b/npq/lib_test.go index e74f0e1..026a701 100644 --- a/npq/lib_test.go +++ b/npq/lib_test.go @@ -48,6 +48,26 @@ func TestSendClosedPanic(t *testing.T) { q.Send(1, 1) } +func TestTooLowPriorityPanic(t *testing.T) { + testInvalidPriorityPanic(t, 0) +} + +func TestTooHighPriorityPanic(t *testing.T) { + testInvalidPriorityPanic(t, 3) +} + +func testInvalidPriorityPanic(t *testing.T, invalid int) { + t.Parallel() + defer func() { + if r := recover(); r == nil { + t.Errorf("sending with invalid priority did not panic") + } + }() + q := npq.Make[int, int](4, 1, 2) + q.Send(invalid, 1) + +} + func TestRecvClosed(t *testing.T) { t.Parallel() q := npq.Make[int, int](4, 1, 2)