Пример #1
0
func TestCircuitAility(t *testing.T) {
	cq := structure.NewCircuitQueue(3)
	cq.Push(1)
	cq.Push(2)
	cq.Shift()
	cq.Push(3)
}
Пример #2
0
func TestIsFull(t *testing.T) {
	cq := structure.NewCircuitQueue(2)
	cq.Push("First")
	if !cq.IsFull() {
		t.Error("It's IsFull is wrong")
	}
}
Пример #3
0
func TestPush(t *testing.T) {
	cq := structure.NewCircuitQueue(5)
	firstElement := "First"
	cq.Push(firstElement)
	if cq.Elements[0] != firstElement {
		t.Error("It's Push Func is wrong, the first elment is:", cq.Elements[0])
	}
}
Пример #4
0
func TestFIFO(t *testing.T) {
	cq := structure.NewCircuitQueue(3)
	cq.Push(1)
	cq.Push(2)
	firstElement := cq.Shift()
	if firstElement != 1 {
		t.Error("It doesn't support FIFO")
	}
}
Пример #5
0
func TestShift(t *testing.T) {
	cq := structure.NewCircuitQueue(5)
	firstElement := "First"
	cq.Push(firstElement)
	e := cq.Shift()
	if e != firstElement {
		t.Error("It can not shift the first element")
	}
}
Пример #6
0
func TestQueueInit(t *testing.T) {
	cq := structure.NewCircuitQueue(5)
	if cq.Size != 5 {
		t.Error("It has wrong size:", cq.Size)
	}

	if !cq.IsEmpty() {
		t.Error("It is not empty")
	}
}
Пример #7
0
func TestIsEmpty(t *testing.T) {
	cq := structure.NewCircuitQueue(5)
	if !cq.IsEmpty() {
		t.Error("It's IsEmpty Func is wrong")
	}
}