Increase code coverage for set_matrix

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
Flavio Crisciani 2017-08-29 17:49:42 -07:00
parent 622f192c35
commit b76166c110

View file

@ -3,6 +3,7 @@ package common
import (
"context"
"strconv"
"strings"
"testing"
"time"
@ -66,6 +67,23 @@ func TestSetSerialInsertDelete(t *testing.T) {
if !b || i != 4 {
t.Fatalf("error in cardinality count %t %d", b, i)
}
keys := s.Keys()
if len(keys) != 1 {
t.Fatalf("error in keys %v", keys)
}
str, b := s.String("a")
if !b ||
!strings.Contains(str, "1") ||
!strings.Contains(str, "2") ||
!strings.Contains(str, "3") ||
!strings.Contains(str, "4") {
t.Fatalf("error in string %t %s", b, str)
}
_, b = s.Get("a")
if !b {
t.Fatalf("error in get %t", b)
}
b, i = s.Remove("a", "1")
if !b || i != 3 {
@ -96,6 +114,27 @@ func TestSetSerialInsertDelete(t *testing.T) {
if b || i != 0 {
t.Fatalf("error in cardinality count %t %d", b, i)
}
str, b = s.String("a")
if b || str != "" {
t.Fatalf("error in string %t %s", b, str)
}
keys = s.Keys()
if len(keys) > 0 {
t.Fatalf("error in keys %v", keys)
}
// Negative tests
_, b = s.Get("not exists")
if b {
t.Fatalf("error should not happen %t", b)
}
b1, b := s.Contains("not exists", "a")
if b1 || b {
t.Fatalf("error should not happen %t %t", b1, b)
}
}
func insertDeleteRotuine(ctx context.Context, endCh chan int, s SetMatrix, key, value string) {