From ed12b310cb34cf7589b62616660a8a35527f2ca7 Mon Sep 17 00:00:00 2001 From: Naoki Kosaka Date: Mon, 11 Feb 2019 18:01:19 +0900 Subject: [PATCH] Add test. --- cli/contain_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cli/contain_test.go diff --git a/cli/contain_test.go b/cli/contain_test.go new file mode 100644 index 0000000..444f201 --- /dev/null +++ b/cli/contain_test.go @@ -0,0 +1,32 @@ +package main + +import "testing" + +func TestContains(t *testing.T) { + data := "nil" + sData := []string{ + "no", + "nil", + } + badData := 0 + result := contains(data, "true") + if result != false { + t.Fatalf("Failed - no contain but true.") + } + result = contains(data, "nil") + if result != true { + t.Fatalf("Failed - contain but false.") + } + result = contains(sData, "true") + if result != false { + t.Fatalf("Failed - no contain but true. (slice)") + } + result = contains(sData, "nil") + if result != true { + t.Fatalf("Failed - contain but false. (slice)") + } + result = contains(badData, "hoge") + if result != false { + t.Fatalf("Failed - input bad data but true. (slice)") + } +}