This commit is contained in:
47
Backend/helper/strings_test.go
Normal file
47
Backend/helper/strings_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user