package torrent
import (
+ "fmt"
"io"
"reflect"
"sync/atomic"
n int64
}
+var _ fmt.Stringer = (*Count)(nil)
+
func (me *Count) Add(n int64) {
atomic.AddInt64(&me.n, n)
}
return atomic.LoadInt64(&me.n)
}
+func (me *Count) String() string {
+ return fmt.Sprintf("%v", me.Int64())
+}
+
func (cs *ConnStats) wroteMsg(msg *pp.Message) {
// TODO: Track messages and not just chunks.
switch msg.Type {
package torrent
import (
+ "reflect"
+ "strings"
"testing"
"github.com/anacrolix/missinggo/bitmap"
"github.com/anacrolix/missinggo/iter"
+ "github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert"
)
assert.Equal(t, []interface{}{0, 3, 2}, iter.ToSlice(iterBitmapsDistinct(&skipCopy, first, second)))
assert.Equal(t, []int{1}, skip.ToSortedSlice())
}
+
+func TestSpewConnStats(t *testing.T) {
+ s := spew.Sdump(ConnStats{})
+ t.Logf("\n%s\n", s)
+ lines := strings.Count(s, "\n")
+ assert.EqualValues(t, 2+reflect.ValueOf(ConnStats{}).NumField(), lines)
+}