add test for unique

This commit is contained in:
Илья Смышляев 2022-09-16 15:40:57 +04:00
parent ca37b583c7
commit b01e6ed906
1 changed files with 47 additions and 0 deletions

47
unique/findunique_test.go Normal file
View File

@ -0,0 +1,47 @@
package unique_test
import (
"fmt"
"gotest/unique"
"testing"
)
// Структура тестовых данных, input - входной массив,
// output - ожидаеммый вывод
type testdata struct {
input []int
output int
}
var test = []testdata{
{[]int{9, 3, 9, 3, 9, 7, 9}, 7},
{[]int{9, 3, 9, 3, 9, 7, 9}, 8},
}
func TestRotation(t *testing.T) {
t.Run(
"insert nums", func(t *testing.T) {
for _, data := range test {
result := unique.FindUnique(data.input)
if result != data.output {
t.Error(
"For: ", data.input,
"Expected: ", data.output,
"Got: ", result,
)
} else {
fmt.Println(
"For: ", data.input,
"Got: ", result,
)
}
}
},
)
}