Example #1
0
func TestClear(t *testing.T) {
	const N = 10
	deque := deque.New()

	for i := 0; i < N; i++ {
		deque.PushFront(i)
	}
	deque.Clear()
	if deque.Size() != 0 {
		t.Errorf("got: %d, want: 0", deque.Size())
	}
}
Example #2
0
func TestSize(t *testing.T) {
	const N = 10
	deque := deque.New()

	if deque.Size() != 0 {
		t.Errorf("got: %d, want: 0", deque.Size())
	}

	for i := 0; i < N; i++ {
		deque.PushFront(i)
	}
	if deque.Size() != N {
		t.Errorf("got: %d, want: %d", deque.Size(), N)
	}
	for deque.Size() > 0 {
		deque.PopFront()
	}
	if deque.Size() != 0 {
		t.Errorf("got: %d, want: 0", deque.Size())
	}

	for i := 0; i < N; i++ {
		deque.PushBack(i)
	}
	if deque.Size() != N {
		t.Errorf("got: %d, want: %d", deque.Size(), N)
	}
	for deque.Size() > 0 {
		deque.PopBack()
	}
	if deque.Size() != 0 {
		t.Errorf("got: %d, want: 0", deque.Size())
	}
}