mirror of
https://github.com/docker/docs.git
synced 2026-03-27 22:38:54 +07:00
pkg: stringutils: Add more tests to strslice
Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user