mirror of https://github.com/tidwall/tinyqueue.git
Remove testify
This commit is contained in:
parent
da19cf886c
commit
c2e3d577e1
2
go.mod
2
go.mod
|
@ -1,5 +1,3 @@
|
||||||
module github.com/tidwall/tinyqueue
|
module github.com/tidwall/tinyqueue
|
||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require github.com/stretchr/testify v1.7.0
|
|
||||||
|
|
10
go.sum
10
go.sum
|
@ -1,10 +0,0 @@
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
|
@ -2,15 +2,20 @@ package tinyqueue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type floatValue float64
|
type floatValue float64
|
||||||
|
|
||||||
|
func assertEqual(t *testing.T, a, b interface{}) {
|
||||||
|
if !reflect.DeepEqual(a, b) {
|
||||||
|
t.Fatalf("'%v' != '%v'", a, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a floatValue) Less(b Item) bool {
|
func (a floatValue) Less(b Item) bool {
|
||||||
return a < b.(floatValue)
|
return a < b.(floatValue)
|
||||||
}
|
}
|
||||||
|
@ -34,12 +39,12 @@ func TestMaintainsPriorityQueue(t *testing.T) {
|
||||||
for i := 0; i < len(data); i++ {
|
for i := 0; i < len(data); i++ {
|
||||||
q.Push(data[i])
|
q.Push(data[i])
|
||||||
}
|
}
|
||||||
assert.Equal(t, q.Peek(), sorted[0])
|
assertEqual(t, q.Peek(), sorted[0])
|
||||||
var result []Item
|
var result []Item
|
||||||
for q.length > 0 {
|
for q.length > 0 {
|
||||||
result = append(result, q.Pop())
|
result = append(result, q.Pop())
|
||||||
}
|
}
|
||||||
assert.Equal(t, result, sorted)
|
assertEqual(t, result, sorted)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAcceptsDataInConstructor(t *testing.T) {
|
func TestAcceptsDataInConstructor(t *testing.T) {
|
||||||
|
@ -48,7 +53,7 @@ func TestAcceptsDataInConstructor(t *testing.T) {
|
||||||
for q.length > 0 {
|
for q.length > 0 {
|
||||||
result = append(result, q.Pop())
|
result = append(result, q.Pop())
|
||||||
}
|
}
|
||||||
assert.Equal(t, result, sorted)
|
assertEqual(t, result, sorted)
|
||||||
}
|
}
|
||||||
func TestHandlesEdgeCasesWithFewElements(t *testing.T) {
|
func TestHandlesEdgeCasesWithFewElements(t *testing.T) {
|
||||||
q := New(nil)
|
q := New(nil)
|
||||||
|
@ -59,7 +64,7 @@ func TestHandlesEdgeCasesWithFewElements(t *testing.T) {
|
||||||
q.Pop()
|
q.Pop()
|
||||||
q.Push(floatValue(2))
|
q.Push(floatValue(2))
|
||||||
q.Push(floatValue(1))
|
q.Push(floatValue(1))
|
||||||
assert.Equal(t, float64(q.Pop().(floatValue)), 1.0)
|
assertEqual(t, float64(q.Pop().(floatValue)), 1.0)
|
||||||
assert.Equal(t, float64(q.Pop().(floatValue)), 2.0)
|
assertEqual(t, float64(q.Pop().(floatValue)), 2.0)
|
||||||
assert.Equal(t, q.Pop(), nil)
|
assertEqual(t, q.Pop(), nil)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue