1 Star 0 Fork 0

Cloudy/guac

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
counted_lock_test.go 677 Bytes
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2019-09-18 10:03 . tests
package guac
import (
"testing"
"time"
)
func TestCountedLock_HasQueued(t *testing.T) {
lock := CountedLock{}
if lock.HasQueued() {
t.Error("Expected false got true (1)")
}
lock.Lock()
if lock.HasQueued() {
t.Error("Expected false got true (2)")
}
go func() {
lock.Lock()
}()
// ensure the goroutine above runs
time.Sleep(time.Millisecond)
if !lock.HasQueued() {
t.Error("Expected true got false")
}
lock.Unlock()
if lock.HasQueued() {
t.Error("Expected false got true (3)")
}
// ensure the lock is taken in the goroutine
time.Sleep(time.Millisecond)
lock.Unlock()
if lock.HasQueued() {
t.Error("Expected false got true (4)")
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/itcloudy/guac.git
git@gitee.com:itcloudy/guac.git
itcloudy
guac
guac
master

搜索帮助