本文整理汇总了Golang中github.com/vys/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestManagerFilterPropSeqn
func TestManagerFilterPropSeqn(t *testing.T) {
ps := make(chan int64, 100)
st := store.New()
defer close(st.Ops)
m := &Manager{
DefRev: 2,
Alpha: 1,
Self: "b",
PSeqn: ps,
Store: st,
}
go m.Run()
st.Ops <- store.Op{1, store.MustEncodeSet("/ctl/cal/0", "a", 0)}
st.Ops <- store.Op{2, store.MustEncodeSet("/ctl/cal/1", "b", 0)}
st.Ops <- store.Op{3, store.Nop}
st.Ops <- store.Op{4, store.Nop}
assert.Equal(t, int64(3), <-ps)
assert.Equal(t, int64(5), <-ps)
st.Ops <- store.Op{5, store.Nop}
st.Ops <- store.Op{6, store.Nop}
assert.Equal(t, int64(7), <-ps)
}
开发者ID:vys,项目名称:doozerd,代码行数:25,代码来源:manager_test.go
示例2: TestRunBroadcastFive
func TestRunBroadcastFive(t *testing.T) {
c := make(chan Packet, 100)
var r run
r.seqn = 1
r.out = c
r.addr = []*net.UDPAddr{
&net.UDPAddr{net.IP{1, 2, 3, 4}, 5},
&net.UDPAddr{net.IP{2, 3, 4, 5}, 6},
&net.UDPAddr{net.IP{3, 4, 5, 6}, 7},
&net.UDPAddr{net.IP{4, 5, 6, 7}, 8},
&net.UDPAddr{net.IP{5, 6, 7, 8}, 9},
}
r.broadcast(newInvite(1))
c <- Packet{}
exp := msg{
Seqn: proto.Int64(1),
Cmd: invite,
Crnd: proto.Int64(1),
}
addr := make([]*net.UDPAddr, len(r.addr))
for i := 0; i < len(r.addr); i++ {
p := <-c
addr[i] = p.Addr
var got msg
err := proto.Unmarshal(p.Data, &got)
assert.Equal(t, nil, err)
assert.Equal(t, exp, got)
}
assert.Equal(t, Packet{}, <-c)
assert.Equal(t, r.addr, addr)
}
开发者ID:vys,项目名称:doozerd,代码行数:35,代码来源:run_test.go
示例3: TestManagerEvent
func TestManagerEvent(t *testing.T) {
const alpha = 2
runs := make(map[int64]*run)
st := store.New()
defer close(st.Ops)
st.Ops <- store.Op{
Seqn: 1,
Mut: store.MustEncodeSet(node+"/a/addr", "1.2.3.4:5", 0),
}
st.Ops <- store.Op{
Seqn: 2,
Mut: store.MustEncodeSet(cal+"/1", "a", 0),
}
ch, err := st.Wait(store.Any, 2)
if err != nil {
panic(err)
}
x, _ := net.ResolveUDPAddr("udp", "1.2.3.4:5")
pseqn := make(chan int64, 1)
m := &Manager{
Alpha: alpha,
Self: "a",
PSeqn: pseqn,
Ops: st.Ops,
Out: make(chan Packet),
run: runs,
}
m.event(<-ch)
exp := &run{
self: "a",
seqn: 2 + alpha,
cals: []string{"a"},
addr: []*net.UDPAddr{x},
ops: st.Ops,
out: m.Out,
bound: initialWaitBound,
}
exp.c = coordinator{
crnd: 1,
size: 1,
quor: exp.quorum(),
}
exp.l = learner{
round: 1,
size: 1,
quorum: int64(exp.quorum()),
votes: map[string]int64{},
voted: []bool{false},
}
assert.Equal(t, 1, len(runs))
assert.Equal(t, exp, runs[exp.seqn])
assert.Equal(t, exp.seqn, <-pseqn)
assert.Equal(t, exp.seqn+1, m.next)
}
开发者ID:vys,项目名称:doozerd,代码行数:60,代码来源:manager_test.go
示例4: TestRecvInvalidPacket
func TestRecvInvalidPacket(t *testing.T) {
q := new(packets)
x := &net.UDPAddr{net.IP{1, 2, 3, 4}, 5}
p := recvPacket(q, Packet{x, invalidProtobuf})
assert.Equal(t, (*packet)(nil), p)
assert.Equal(t, 0, q.Len())
}
开发者ID:vys,项目名称:doozerd,代码行数:7,代码来源:manager_test.go
示例5: TestCoordQuorum
func TestCoordQuorum(t *testing.T) {
co := coordinator{
size: 10,
quor: 6,
crnd: 1,
}
co.update(&packet{msg: *newPropose("foo")}, -1)
got, tick := co.update(newRsvpFrom(1, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
got, tick = co.update(newRsvpFrom(2, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
got, tick = co.update(newRsvpFrom(3, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
got, tick = co.update(newRsvpFrom(4, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
got, tick = co.update(newRsvpFrom(5, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
}
开发者ID:vys,项目名称:doozerd,代码行数:29,代码来源:coordinator_test.go
示例6: TestCoordStart
func TestCoordStart(t *testing.T) {
co := coordinator{crnd: 1}
got, tick := co.update(&packet{msg: *newPropose("foo")}, -1)
assert.Equal(t, newInvite(1), got)
assert.Equal(t, true, tick)
}
开发者ID:vys,项目名称:doozerd,代码行数:7,代码来源:coordinator_test.go
示例7: TestEventIsSet
func TestEventIsSet(t *testing.T) {
p, v := "/x", "a"
m := MustEncodeSet(p, v, Clobber)
ev := Event{1, p, v, 1, m, nil, nil}
assert.Equal(t, true, ev.IsSet())
assert.Equal(t, false, ev.IsDel())
assert.Equal(t, false, ev.IsNop())
}
开发者ID:vys,项目名称:doozerd,代码行数:8,代码来源:event_test.go
示例8: TestRecvEmptyPacket
func TestRecvEmptyPacket(t *testing.T) {
q := new(packets)
x := &net.UDPAddr{net.IP{1, 2, 3, 4}, 5}
p := recvPacket(q, Packet{x, []byte{}})
assert.Equal(t, (*packet)(nil), p)
assert.Equal(t, 0, q.Len())
}
开发者ID:vys,项目名称:doozerd,代码行数:8,代码来源:manager_test.go
示例9: TestEventIsDel
func TestEventIsDel(t *testing.T) {
p := "/x"
m := MustEncodeDel(p, Clobber)
ev := Event{1, p, "", Missing, m, nil, nil}
assert.Equal(t, true, ev.IsDel())
assert.Equal(t, false, ev.IsSet())
assert.Equal(t, false, ev.IsNop())
}
开发者ID:vys,项目名称:doozerd,代码行数:8,代码来源:event_test.go
示例10: TestLivenessNoCheck
func TestLivenessNoCheck(t *testing.T) {
a := &net.UDPAddr{net.IP{1, 2, 3, 4}, 5}
lv := liveness{
prev: 5,
ival: 3,
times: []liverec{{a, 5}},
}
lv.check(7)
assert.Equal(t, int64(5), lv.prev)
assert.Equal(t, []liverec{{a, 5}}, lv.times)
}
开发者ID:vys,项目名称:doozerd,代码行数:11,代码来源:liveness_test.go
示例11: TestSchedTrigger
func TestSchedTrigger(t *testing.T) {
var q triggers
d := int64(15e8)
t0 := time.Now().UnixNano()
ts := t0 + d
schedTrigger(&q, 1, t0, d)
assert.Equal(t, 1, q.Len())
f := q[0]
assert.Equal(t, int64(1), f.n)
assert.T(t, f.t == ts)
}
开发者ID:vys,项目名称:doozerd,代码行数:13,代码来源:manager_test.go
示例12: TestGcPulse
func TestGcPulse(t *testing.T) {
seqns := make(chan int64)
defer close(seqns)
fs := make(FakeProposer)
go Pulse("test", seqns, fs, 1)
seqns <- 0
assert.Equal(t, "-1:/ctl/node/test/applied=0", <-fs)
seqns <- 1
assert.Equal(t, "-1:/ctl/node/test/applied=1", <-fs)
}
开发者ID:vys,项目名称:doozerd,代码行数:13,代码来源:pulse_test.go
示例13: TestLivenessStaysAlive
func TestLivenessStaysAlive(t *testing.T) {
shun := make(chan string, 1)
a := &net.UDPAddr{net.IP{1, 2, 3, 4}, 5}
lv := liveness{
prev: 0,
ival: 1,
timeout: 3,
times: []liverec{{a, 5}},
shun: shun,
}
lv.check(7)
assert.Equal(t, int64(7), lv.prev)
assert.Equal(t, 0, len(shun))
assert.Equal(t, []liverec{{a, 5}}, lv.times)
}
开发者ID:vys,项目名称:doozerd,代码行数:15,代码来源:liveness_test.go
示例14: TestCoordTargetNomination
func TestCoordTargetNomination(t *testing.T) {
co := coordinator{crnd: 1, quor: 6, size: 10}
co.update(&packet{msg: *newPropose("foo")}, -1)
co.update(newRsvpFrom(1, 1, 0, ""))
co.update(newRsvpFrom(2, 1, 0, ""))
co.update(newRsvpFrom(3, 1, 0, ""))
co.update(newRsvpFrom(4, 1, 0, ""))
co.update(newRsvpFrom(5, 1, 0, ""))
got, tick := co.update(newRsvpFrom(6, 1, 0, ""))
assert.Equal(t, newNominate(1, "foo"), got)
assert.Equal(t, false, tick)
}
开发者ID:vys,项目名称:doozerd,代码行数:15,代码来源:coordinator_test.go
示例15: TestCoordStartRsvp
func TestCoordStartRsvp(t *testing.T) {
co := coordinator{
quor: 1,
crnd: 1,
}
got, tick := co.update(newRsvpFrom(0, 1, 0, ""))
assert.Equal(t, (*msg)(nil), got)
assert.Equal(t, false, tick)
got, tick = co.update(&packet{msg: *newPropose("foo")}, -1)
// If the RSVPs were ignored, this will be an invite.
// Otherwise, it'll be a nominate.
assert.Equal(t, newInvite(1), got)
assert.Equal(t, true, tick)
}
开发者ID:vys,项目名称:doozerd,代码行数:17,代码来源:coordinator_test.go
示例16: TestLivenessTimesOut
func TestLivenessTimesOut(t *testing.T) {
shun := make(chan string, 1)
a := &net.UDPAddr{net.IP{1, 2, 3, 4}, 5}
lv := liveness{
prev: 0,
ival: 1,
timeout: 3,
times: []liverec{{a, 5}},
shun: shun,
self: &net.UDPAddr{net.IP{2, 3, 4, 5}, 6},
}
lv.check(9)
assert.Equal(t, int64(9), lv.prev)
assert.Equal(t, 1, len(shun))
assert.Equal(t, "1.2.3.4:5", <-shun)
assert.Equal(t, []liverec{}, lv.times)
}
开发者ID:vys,项目名称:doozerd,代码行数:17,代码来源:liveness_test.go
示例17: TestRunProposeDelivered
func TestRunProposeDelivered(t *testing.T) {
var r run
r.out = make(chan Packet, 100)
r.ops = make(chan store.Op, 100)
r.update(&packet{msg: msg{Cmd: propose}}, -1, new(triggers))
assert.Equal(t, true, r.c.begun)
}
开发者ID:vys,项目名称:doozerd,代码行数:8,代码来源:run_test.go
示例18: TestQuorum
func TestQuorum(t *testing.T) {
assert.Equal(t, 1, (&run{cals: []string{"a"}}).quorum())
assert.Equal(t, 2, (&run{cals: []string{"a", "b"}}).quorum())
assert.Equal(t, 2, (&run{cals: []string{"a", "b", "c"}}).quorum())
assert.Equal(t, 3, (&run{cals: []string{"a", "b", "c", "d"}}).quorum())
assert.Equal(t, 3, (&run{cals: []string{"a", "b", "c", "d", "e"}}).quorum())
assert.Equal(t, 4, (&run{cals: []string{"a", "b", "c", "d", "e", "f"}}).quorum())
assert.Equal(t, 4, (&run{cals: []string{"a", "b", "c", "d", "e", "f", "g"}}).quorum())
assert.Equal(t, 5, (&run{cals: []string{"a", "b", "c", "d", "e", "f", "g", "h"}}).quorum())
}
开发者ID:vys,项目名称:doozerd,代码行数:10,代码来源:run_test.go
示例19: TestMemberSimple
func TestMemberSimple(t *testing.T) {
st := store.New()
defer close(st.Ops)
fp := &test.FakeProposer{Store: st}
c := make(chan string)
go Clean(c, fp.Store, fp)
fp.Propose([]byte(store.MustEncodeSet("/ctl/node/a/x", "a", store.Missing)))
fp.Propose([]byte(store.MustEncodeSet("/ctl/node/a/y", "b", store.Missing)))
fp.Propose([]byte(store.MustEncodeSet("/ctl/node/a/addr", "1.2.3.4", store.Missing)))
fp.Propose([]byte(store.MustEncodeSet("/ctl/cal/0", "a", store.Missing)))
calCh, err := fp.Wait(store.MustCompileGlob("/ctl/cal/0"), 1+<-fp.Seqns)
if err != nil {
panic(err)
}
nodeCh, err := fp.Wait(store.MustCompileGlob("/ctl/node/a/?"), 1+<-fp.Seqns)
if err != nil {
panic(err)
}
// indicate that this peer is inactive
go func() { c <- "1.2.3.4" }()
ev := <-calCh
assert.T(t, ev.IsSet())
assert.Equal(t, "", ev.Body)
cs := []int{}
ev = <-nodeCh
assert.T(t, ev.IsDel())
cs = append(cs, int(ev.Path[len(ev.Path)-1]))
nodeCh, err = fp.Wait(store.MustCompileGlob("/ctl/node/a/?"), ev.Seqn+1)
if err != nil {
panic(err)
}
ev = <-nodeCh
assert.T(t, ev.IsDel())
cs = append(cs, int(ev.Path[len(ev.Path)-1]))
sort.Ints(cs)
assert.Equal(t, []int{'x', 'y'}, cs)
}
开发者ID:vys,项目名称:doozerd,代码行数:45,代码来源:member_test.go
示例20: TestRunInviteDelivered
func TestRunInviteDelivered(t *testing.T) {
var r run
r.out = make(chan Packet, 100)
r.ops = make(chan store.Op, 100)
r.update(&packet{msg: *newInviteSeqn1(1)}, 0, new(triggers))
assert.Equal(t, int64(1), r.a.rnd)
}
开发者ID:vys,项目名称:doozerd,代码行数:9,代码来源:run_test.go
注:本文中的github.com/vys/assert.Equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论