示例#1
0
func TestPushPeek(t *testing.T) {
	deque := deque.New()

	deque.PushFront("a")
	if deque.FrontItem() != "a" {
		t.Errorf("got: %v, want: a", deque.FrontItem())
	}

	deque.PushBack("z")
	if deque.BackItem() != "z" {
		t.Errorf("got: %v, want: z", deque.BackItem())
	}
}
示例#2
0
func BenchmarkBackItem(b *testing.B) {
	const N = 16
	deque := deque.New()
	for i := 0; i < N; i++ {
		deque.PushBack(i)
	}
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		_ = deque.BackItem()
	}
}
示例#3
0
func TestEmpty_item(t *testing.T) {
	deque := deque.New()

	frontItem := deque.FrontItem()
	if frontItem != nil {
		t.Errorf("got: %v, want: <nil>", frontItem)
	}

	backItem := deque.BackItem()
	if backItem != nil {
		t.Errorf("got: %v, want: <nil>", backItem)
	}
}