Checkpoint
This commit is contained in:
31
dataset/parser/parser_test.go
Normal file
31
dataset/parser/parser_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUnique(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Test []string
|
||||
Want []string
|
||||
}{
|
||||
{"nil", nil, nil},
|
||||
{"single", []string{"test"}, []string{"test"}},
|
||||
{"duplicate", []string{"test", "test"}, []string{"test"}},
|
||||
{"multiple", []string{"a", "a", "b", "b", "b", "c"}, []string{"a", "b", "c"}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(it *testing.T) {
|
||||
v := unique(test.Test)
|
||||
if v != nil {
|
||||
sort.Strings(v)
|
||||
}
|
||||
if !reflect.DeepEqual(v, test.Want) {
|
||||
it.Errorf("expected unique(%v) to return %v, got %v", test.Test, test.Want, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user