mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-30 16:18:40 +01:00
20210109
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func search(n int, nums []int) int {
|
||||||
|
l := len(nums)
|
||||||
|
c := l / 2
|
||||||
|
for {
|
||||||
|
if c == 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func Test_search(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
n int
|
||||||
|
nums []int
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"test1",
|
||||||
|
args{9, []int{-1, 0, 3, 5, 9, 12}},
|
||||||
|
4,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := search(tt.args.n, tt.args.nums); got != tt.want {
|
||||||
|
t.Errorf("search() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user