Improve code coverage

This commit is contained in:
Emir Pasic
2022-04-13 16:52:21 +02:00
parent e2b92bbc7a
commit 41012c6c58
18 changed files with 359 additions and 3 deletions
+19
View File
@@ -116,6 +116,12 @@ func TestStackIteratorNext(t *testing.T) {
if actualValue, expectedValue := count, 3; actualValue != expectedValue {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}
stack.Clear()
it = stack.Iterator()
for it.Next() {
t.Errorf("Shouldn't iterate on empty stack")
}
}
func TestStackIteratorPrev(t *testing.T) {
@@ -371,6 +377,19 @@ func TestStackSerialization(t *testing.T) {
if err != nil {
t.Errorf("Got error %v", err)
}
err = json.Unmarshal([]byte(`[1,2,3]`), &stack)
if err != nil {
t.Errorf("Got error %v", err)
}
}
func TestStackString(t *testing.T) {
c := New()
c.Push(1)
if !strings.HasPrefix(c.String(), "ArrayStack") {
t.Errorf("String should start with container name")
}
}
func benchmarkPush(b *testing.B, stack *Stack, size int) {