2018-11-22 15:05:42 +00:00
|
|
|
package curl2info
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPQueue(t *testing.T) {
|
2018-11-23 07:30:52 +00:00
|
|
|
PQExec := newPQueueExecute()
|
2018-11-29 08:19:40 +00:00
|
|
|
PQExec.Push(&parseFunction{Priority: 5})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 10})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 4})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 4})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 20})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 10})
|
|
|
|
PQExec.Push(&parseFunction{Priority: 15})
|
2018-11-22 15:05:42 +00:00
|
|
|
|
|
|
|
content := ""
|
|
|
|
for PQExec.Len() > 0 {
|
2018-11-29 08:19:40 +00:00
|
|
|
content += strconv.Itoa(PQExec.Pop().Priority)
|
2018-11-22 15:05:42 +00:00
|
|
|
content += " "
|
|
|
|
}
|
|
|
|
if content != "4 4 5 10 10 15 20 " {
|
|
|
|
t.Error(content)
|
|
|
|
}
|
|
|
|
}
|