mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg: stringutils: Add more tests to strslice
Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
parent
82415adc81
commit
cac8f4f0d0
1 changed files with 30 additions and 0 deletions
|
@ -2,6 +2,7 @@ package stringutils
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -103,3 +104,32 @@ func TestStrSliceToString(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStrSliceLen(t *testing.T) {
|
||||
var emptyStrSlice *StrSlice
|
||||
slices := map[*StrSlice]int{
|
||||
NewStrSlice(""): 1,
|
||||
NewStrSlice("one"): 1,
|
||||
NewStrSlice("one", "two"): 2,
|
||||
emptyStrSlice: 0,
|
||||
}
|
||||
for s, expected := range slices {
|
||||
if s.Len() != expected {
|
||||
t.Fatalf("Expected %d, got %d", s.Len(), expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStrSliceSlice(t *testing.T) {
|
||||
var emptyStrSlice *StrSlice
|
||||
slices := map[*StrSlice][]string{
|
||||
NewStrSlice("one"): {"one"},
|
||||
NewStrSlice("one", "two"): {"one", "two"},
|
||||
emptyStrSlice: nil,
|
||||
}
|
||||
for s, expected := range slices {
|
||||
if !reflect.DeepEqual(s.Slice(), expected) {
|
||||
t.Fatalf("Expected %v, got %v", s.Slice(), expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue