6 pp "github.com/anacrolix/torrent/peer_protocol"
7 qt "github.com/frankban/quicktest"
10 func keysAsSlice(m map[Request]struct{}) (sl []Request) {
17 func makeTypicalRequests() map[Request]struct{} {
18 m := make(map[Request]struct{})
19 for p := pp.Integer(0); p < 4; p++ {
20 for c := pp.Integer(0); c < 16; c++ {
21 m[Request{p, ChunkSpec{c * defaultChunkSize, defaultChunkSize}}] = struct{}{}
27 func TestLogExampleRequestMapOrdering(t *testing.T) {
28 for k := range makeTypicalRequests() {
33 func TestRequestMapOrderingPersistent(t *testing.T) {
34 m := makeTypicalRequests()
35 // Shows that map order is persistent across separate range statements.
36 qt.Assert(t, keysAsSlice(m), qt.ContentEquals, keysAsSlice(m))
39 func TestRequestMapOrderAcrossInstances(t *testing.T) {
40 // This shows that different map instances with the same contents can have the same range order.
41 qt.Assert(t, keysAsSlice(makeTypicalRequests()), qt.ContentEquals, keysAsSlice(makeTypicalRequests()))