32 lines
604 B
Go
32 lines
604 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestContains_Found(t *testing.T) {
|
|
slice := []int{1, 2, 3, 4, 5}
|
|
if !contains(slice, 3) {
|
|
t.Error("contains({1,2,3,4,5}, 3) = false, want true")
|
|
}
|
|
}
|
|
|
|
func TestContains_NotFound(t *testing.T) {
|
|
slice := []int{1, 2, 3, 4, 5}
|
|
if contains(slice, 6) {
|
|
t.Error("contains({1,2,3,4,5}, 6) = true, want false")
|
|
}
|
|
}
|
|
|
|
func TestContains_Empty(t *testing.T) {
|
|
if contains(nil, 1) {
|
|
t.Error("contains(nil, 1) = true, want false")
|
|
}
|
|
}
|
|
|
|
func TestContains_First(t *testing.T) {
|
|
if !contains([]int{42}, 42) {
|
|
t.Error("contains({42}, 42) = false, want true")
|
|
}
|
|
}
|