From ce6f3182a2c9656910a75687565fb193b446f458 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 3 Dec 2019 09:53:05 +0100 Subject: [PATCH] utils --- pkg/utils/formParser.go | 1 - pkg/utils/strings_test.go | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) delete mode 100644 pkg/utils/formParser.go create mode 100644 pkg/utils/strings_test.go diff --git a/pkg/utils/formParser.go b/pkg/utils/formParser.go deleted file mode 100644 index d4b585b..0000000 --- a/pkg/utils/formParser.go +++ /dev/null @@ -1 +0,0 @@ -package utils diff --git a/pkg/utils/strings_test.go b/pkg/utils/strings_test.go new file mode 100644 index 0000000..86af2af --- /dev/null +++ b/pkg/utils/strings_test.go @@ -0,0 +1,48 @@ +package utils + +import "testing" + +func TestContains(t *testing.T) { + type args struct { + list []string + needle string + } + tests := []struct { + name string + args args + want bool + }{ + { + "empty list false", + args{[]string{}, "needle"}, + false, + }, + { + "list not containing false", + args{[]string{"list"}, "needle"}, + false, + }, + { + "list not containing empty needle false", + args{[]string{"list", "needle"}, ""}, + false, + }, + { + "list containing true", + args{[]string{"list", "needle"}, "needle"}, + true, + }, + { + "list containing empty needle true", + args{[]string{"list", "needle", ""}, ""}, + true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Contains(tt.args.list, tt.args.needle); got != tt.want { + t.Errorf("Contains() = %v, want %v", got, tt.want) + } + }) + } +}