1 Star 0 Fork 1

lsj/go-torrent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
worse-conns_test.go 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
package torrent
import (
"testing"
"time"
qt "github.com/frankban/quicktest"
)
func TestWorseConnLastHelpful(t *testing.T) {
c := qt.New(t)
c.Check((&worseConnInput{}).Less(&worseConnInput{LastHelpful: time.Now()}), qt.IsTrue)
c.Check((&worseConnInput{}).Less(&worseConnInput{CompletedHandshake: time.Now()}), qt.IsTrue)
c.Check((&worseConnInput{LastHelpful: time.Now()}).Less(&worseConnInput{CompletedHandshake: time.Now()}), qt.IsFalse)
c.Check((&worseConnInput{
LastHelpful: time.Now(),
}).Less(&worseConnInput{
LastHelpful: time.Now(),
CompletedHandshake: time.Now(),
}), qt.IsTrue)
now := time.Now()
c.Check((&worseConnInput{
LastHelpful: now,
}).Less(&worseConnInput{
LastHelpful: now.Add(-time.Nanosecond),
CompletedHandshake: now,
}), qt.IsFalse)
readyPeerPriority := func() (peerPriority, error) {
return 42, nil
}
c.Check((&worseConnInput{
GetPeerPriority: readyPeerPriority,
}).Less(&worseConnInput{
GetPeerPriority: readyPeerPriority,
Pointer: 1,
}), qt.IsTrue)
c.Check((&worseConnInput{
GetPeerPriority: readyPeerPriority,
Pointer: 2,
}).Less(&worseConnInput{
GetPeerPriority: readyPeerPriority,
Pointer: 1,
}), qt.IsFalse)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/leesj/go-torrent.git
git@gitee.com:leesj/go-torrent.git
leesj
go-torrent
go-torrent
master

搜索帮助