예제 #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)
}
예제 #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)
}
예제 #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)
}
예제 #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)
}
예제 #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)
}
예제 #6
0
func (s *S) TestChooseEmpty(c *C) {
	r := BA.NewRoundRobin([]string{})
	c.Assert(r.Choose(), Equals, nil)
}
예제 #7
0
func (s *S) TestLen(c *C) {
	r := BA.NewRoundRobin([]string{a, b})
	c.Assert(r.Len(), Equals, 2)
}