PriorityQueue test move to struture_test.go
This commit is contained in:
parent
2127db6ce2
commit
4fc3a91d35
25
base_test.go
25
base_test.go
|
@ -1,26 +1 @@
|
||||||
package curl2info
|
package curl2info
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestPQueue(t *testing.T) {
|
|
||||||
PQExec := newPQueueExecute()
|
|
||||||
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})
|
|
||||||
|
|
||||||
content := ""
|
|
||||||
for PQExec.Len() > 0 {
|
|
||||||
content += strconv.Itoa(PQExec.Pop().Priority)
|
|
||||||
content += " "
|
|
||||||
}
|
|
||||||
if content != "4 4 5 10 10 15 20 " {
|
|
||||||
t.Error(content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +1,26 @@
|
||||||
package curl2info
|
package curl2info
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPQueue(t *testing.T) {
|
||||||
|
PQExec := newPQueueExecute()
|
||||||
|
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})
|
||||||
|
|
||||||
|
content := ""
|
||||||
|
for PQExec.Len() > 0 {
|
||||||
|
content += strconv.Itoa(PQExec.Pop().Priority)
|
||||||
|
content += " "
|
||||||
|
}
|
||||||
|
if content != "4 4 5 10 10 15 20 " {
|
||||||
|
t.Error(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user