1 Star 0 Fork 34

maxid / distributed-gosuv

forked from haiker / sudis 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
broadcast_test.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
haiker 提交于 2017-12-03 19:46 . 分布式实现
package main
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
// func TestBroadcast(t *testing.T) {
// bs := NewBroadcastString()
// bs.WriteMessage("hello")
// time.Sleep(10 * time.Millisecond)
// c1 := bs.AddListener(nil)
// go func() {
// bs.WriteMessage("world")
// }()
// message := <-c1
// if message != "world" {
// t.Fatalf("expect message world, but got %s", message)
// }
// c2 := bs.AddListener(nil)
// go func() {
// bs.WriteMessage("tab")
// }()
// // test write multi
// wg := sync.WaitGroup{}
// wg.Add(2)
// go func() {
// message = <-c2
// if message != "tab" {
// t.Errorf("expect tab, but got %s", message)
// }
// wg.Done()
// }()
// go func() {
// message = <-c1
// if message != "tab" {
// t.Errorf("expect tab, but got %s", message)
// }
// wg.Done()
// }()
// wg.Wait()
// }
func TestRingBuffer(t *testing.T) {
Convey("Write some string to ring buffer", t, func() {
// buf := rbuf.NewFixedSizeRingBuf(5)
// buf.Write([]byte("abcde"))
// So(string(buf.Bytes()), ShouldEqual, "abcde")
// buf.Advance(2)
// buf.Write([]byte("fg"))
// So(string(buf.Bytes()), ShouldEqual, "cdefg")
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/istyle/distributed-gosuv.git
git@gitee.com:istyle/distributed-gosuv.git
istyle
distributed-gosuv
distributed-gosuv
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891