48 lines
871 B
Go
48 lines
871 B
Go
package helper
|
|
|
|
import "testing"
|
|
|
|
func TestGetFirst(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
a any
|
|
b any
|
|
want any
|
|
}{
|
|
{"ints", 10, 20, 10},
|
|
{"strings", "first", "second", "first"},
|
|
{"mixed", "abc", 123, "abc"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := GetFirst(tt.a, tt.b)
|
|
if got != tt.want {
|
|
t.Errorf("GetFirst(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestGetSecond(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
a any
|
|
b any
|
|
want any
|
|
}{
|
|
{"ints", 10, 20, 20},
|
|
{"strings", "first", "second", "second"},
|
|
{"mixed", "abc", 123, 123},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := GetSecond(tt.a, tt.b)
|
|
if got != tt.want {
|
|
t.Errorf("GetSecond(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|