(doc): filter_test.go

This commit is contained in:
bfu4 2021-09-06 14:36:18 -04:00
parent b455a5af11
commit d0c05f3eff
No known key found for this signature in database
GPG Key ID: FD1D952871D22043

@ -7,9 +7,10 @@ import (
"testing"
)
// Test the filtering function MappableList.Filter(Predicate).
func TestFilter(t *testing.T) {
stringMap := gomap.New("test", "test1", "test2", "not_applicable", "test3")
mappable := gomap.MappableList{List: stringMap}
mappable := stringMap.Mappable()
filtered := mappable.Filter(func(i interface{}) bool {
if str, ok := i.(string); ok {
return strings.Contains(str, "test")
@ -23,6 +24,7 @@ func TestFilter(t *testing.T) {
}
}
// Benchmark the filtering function.
func BenchmarkFilter(b *testing.B) {
stringMap := gomap.New("test", "test1", "test2", "not_applicable", "test3")
mappable := stringMap.Mappable()
@ -42,6 +44,7 @@ func BenchmarkFilter(b *testing.B) {
}
}
// Map an interface array to a string.
func mapToString(i []interface{}) []string {
var strArr []string
for _, v := range i {