diff --git a/stringutils/strslice_test.go b/stringutils/strslice_test.go index d0e6b1b..a587784 100644 --- a/stringutils/strslice_test.go +++ b/stringutils/strslice_test.go @@ -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) + } + } +}