func TestAddBall(t *testing.T) {
	bt := newBallTrack(1)
	b := ball.New(1)
	suc := bt.addBall(b)

	if !suc {
		t.Errorf("Add Ball failed! Expected true, actual %t", suc)
	}

	b = ball.New(2)
	suc = bt.addBall(b)

	if suc {
		t.Errorf("Add Ball failed! Expected false, actual %t", suc)
	}
}
Beispiel #2
0
func NewQueueTrack(cap uint8) *QueueTrack {
	q := new(QueueTrack)
	q.ballTrack = newBallTrack(cap)

	for i := uint8(0); i < cap; i++ {
		q.addBall(ball.New(i + 1))
	}

	return q
}
func TestGetContents(t *testing.T) {
	bt := newBallTrack(5)
	e := []int{0, 1, 2, 3}
	for i := range e {
		bt.addBall(ball.New(uint8(e[i])))
	}

	c := bt.GetContentIds()
	for i := range e {
		if c[i] != e[i] {
			t.Errorf("Get Contents failed, expected %d, actual %d", e[i], c[i])
		}
	}
}
func TestIsFull(t *testing.T) {
	bt := newBallTrack(1)
	suc := bt.isFull()
	if suc {
		t.Errorf("isFull() failed! Expected false, actual %t", suc)
	}

	bt.balls[0] = ball.New(0)
	bt.currentPos += 1
	suc = bt.isFull()
	if !suc {
		t.Errorf("isFull() failed! Expected true, actual %t", suc)
	}
}