Merge pull request #1927 from fcrisciani/increase-cov
Increase code coverage for set_matrix
This commit is contained in:
commit
6b3ec6b965
1 changed files with 39 additions and 0 deletions
|
@ -3,6 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -66,6 +67,23 @@ func TestSetSerialInsertDelete(t *testing.T) {
|
||||||
if !b || i != 4 {
|
if !b || i != 4 {
|
||||||
t.Fatalf("error in cardinality count %t %d", b, i)
|
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")
|
b, i = s.Remove("a", "1")
|
||||||
if !b || i != 3 {
|
if !b || i != 3 {
|
||||||
|
@ -96,6 +114,27 @@ func TestSetSerialInsertDelete(t *testing.T) {
|
||||||
if b || i != 0 {
|
if b || i != 0 {
|
||||||
t.Fatalf("error in cardinality count %t %d", b, i)
|
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) {
|
func insertDeleteRotuine(ctx context.Context, endCh chan int, s SetMatrix, key, value string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue