Exemplo n.º 1
0
func (s *S) TestAddEmpty(c *C) {
	r := BA.NewRoundRobin([]string{})
	c.Assert(r.Len(), Equals, 0)
	r.Add(a)
	c.Assert(r.Len(), Equals, 1)
	c.Assert(r.Choose().String(), Equals, a)
}
Exemplo n.º 2
0
func (s *S) TestChoose(c *C) {
	r := BA.NewRoundRobin([]string{a, b})
	c.Assert(r.Choose().String(), Equals, a)
	c.Assert(r.Choose().String(), Equals, b)
	c.Assert(r.Choose().String(), Equals, a)
	c.Assert(r.Choose().String(), Equals, b)
}
Exemplo n.º 3
0
func (s *S) TestAdd(c *C) {
	r := BA.NewRoundRobin([]string{a})
	c.Assert(r.Choose().String(), Equals, a)
	c.Assert(r.Choose().String(), Equals, a)
	r.Add(b)
	c.Assert(r.Choose().String(), Equals, b)
	c.Assert(r.Choose().String(), Equals, a)
}
Exemplo n.º 4
0
func (s *S) TestRemoveEmpty(c *C) {
	r := BA.NewRoundRobin([]string{})
	c.Assert(r.Len(), Equals, 0)
	r.Remove(a)
	c.Assert(r.Len(), Equals, 0)
	r.Add(a)
	c.Assert(r.Len(), Equals, 1)
	r.Remove(a)
	c.Assert(r.Len(), Equals, 0)
	r.Remove(a)
}
Exemplo n.º 5
0
func (s *S) TestRemove(c *C) {
	r := BA.NewRoundRobin([]string{a, b})
	c.Assert(r.Len(), Equals, 2)
	c.Assert(r.Choose().String(), Equals, a)
	c.Assert(r.Choose().String(), Equals, b)
	r.Remove(b)
	c.Assert(r.Len(), Equals, 1)
	c.Assert(r.Choose().String(), Equals, a)
	c.Assert(r.Choose().String(), Equals, a)
	r.Remove(a)
	c.Assert(r.Len(), Equals, 0)
}
Exemplo n.º 6
0
func (s *S) TestChooseEmpty(c *C) {
	r := BA.NewRoundRobin([]string{})
	c.Assert(r.Choose(), Equals, nil)
}
Exemplo n.º 7
0
func (s *S) TestLen(c *C) {
	r := BA.NewRoundRobin([]string{a, b})
	c.Assert(r.Len(), Equals, 2)
}