Merge Go frontend (apiserver + xcecli) into meson build
This commit is contained in:
parent
43dc12a36c
commit
c9dc8c4676
205 changed files with 30793 additions and 328 deletions
37
src/frontend/apiserver/utils/utils_test.go
Normal file
37
src/frontend/apiserver/utils/utils_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIntOrInt64(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input interface{}
|
||||
want int
|
||||
ok bool
|
||||
}{
|
||||
{"int zero", int(0), 0, true},
|
||||
{"int positive", int(42), 42, true},
|
||||
{"int negative", int(-1), -1, true},
|
||||
{"int64 zero", int64(0), 0, true},
|
||||
{"int64 positive", int64(42), 42, true},
|
||||
{"int64 negative", int64(-1), -1, true},
|
||||
{"int64 large", int64(9223372036854775807), int(9223372036854775807), true}, // int==int64 on 64-bit
|
||||
{"string", "42", 0, false},
|
||||
{"float64", 42.0, 0, false},
|
||||
{"nil", nil, 0, false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, ok := IntOrInt64(tt.input)
|
||||
if ok != tt.ok {
|
||||
t.Errorf("IntOrInt64(%v) ok = %v, want %v", tt.input, ok, tt.ok)
|
||||
}
|
||||
if ok && got != tt.want {
|
||||
t.Errorf("IntOrInt64(%v) = %d, want %d", tt.input, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue