Skip to content

Commit

Permalink
Add test for missing edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
jupp0r committed May 31, 2016
1 parent 58d0658 commit 04aad4a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions priorty_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,19 @@ func TestPopEmptyQueue(t *testing.T) {
t.Fatal("should produce error when performing pop on empty queue")
}
}

func TestUpdateNonExistingItem(t *testing.T) {
pq := New()

pq.Insert("foo", 4)
pq.UpdatePriority("bar", 5)

if pq.Len() != 1 {
t.Fatal("update should not add items")
}

item, _ := pq.Pop()
if item.(string) != "foo" {
t.Fatalf("update should not overwrite item, expected \"foo\", got \"%v\"", item.(string))
}
}

0 comments on commit 04aad4a

Please sign in to comment.