Add test.
This commit is contained in:
parent
664d0cf3b3
commit
ed12b310cb
32
cli/contain_test.go
Normal file
32
cli/contain_test.go
Normal file
@ -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)")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user