本文整理汇总了Golang中github.com/vys/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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)
}
示例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)
}
示例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())
}
示例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)
}
示例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)
}
示例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())
}
示例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())
}
示例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())
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}