From c2e0726105cc811a456d900c62443159acc29c32 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 16 May 2024 17:54:30 +0200 Subject: pkg/fuzzer/queue: simplify the priority queue We don't need the full priority queue functionality anymore. For our purposes it's enough to only enforce the order between the elements of different sub-queues. --- pkg/fuzzer/queue/prio_queue_test.go | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'pkg/fuzzer/queue/prio_queue_test.go') diff --git a/pkg/fuzzer/queue/prio_queue_test.go b/pkg/fuzzer/queue/prio_queue_test.go index a82886bdd..76d4b836b 100644 --- a/pkg/fuzzer/queue/prio_queue_test.go +++ b/pkg/fuzzer/queue/prio_queue_test.go @@ -9,32 +9,15 @@ import ( "github.com/stretchr/testify/assert" ) -func TestNextPriority(t *testing.T) { - first := priority{0} - second := first.next() - third := second.next() - assert.True(t, first.greaterThan(second)) - assert.True(t, second.greaterThan(third)) -} - -func TestPriority(t *testing.T) { - assert.True(t, priority{1, 2}.greaterThan(priority{1, 1})) - assert.True(t, priority{3, 2}.greaterThan(priority{2, 3})) - assert.True(t, priority{1, -5}.greaterThan(priority{1, -10})) - assert.True(t, priority{1}.greaterThan(priority{1, -1})) - assert.False(t, priority{1}.greaterThan(priority{1, 1})) - assert.True(t, priority{1, 0}.greaterThan(priority{1})) -} - func TestPrioQueueOrder(t *testing.T) { pq := priorityQueueOps[int]{} - pq.Push(1, priority{1}) - pq.Push(3, priority{3}) - pq.Push(2, priority{2}) + pq.Push(1, 1) + pq.Push(3, 3) + pq.Push(2, 2) - assert.Equal(t, 3, pq.Pop()) - assert.Equal(t, 2, pq.Pop()) assert.Equal(t, 1, pq.Pop()) + assert.Equal(t, 2, pq.Pop()) + assert.Equal(t, 3, pq.Pop()) assert.Zero(t, pq.Pop()) assert.Zero(t, pq.Len()) } -- cgit mrf-deployment