mirror of
https://github.com/hanzoai/go-openai-realtime.git
synced 2026-09-30 21:54:42 +00:00
Hard-fork of WqyJh/go-openai-realtime (v0.5.x line, commit 3f3cf7a) into the
hanzoai org so the OpenAI/audio-LLM Go stack is fully owned. Renames the module
path across root, contrib/ws-gorilla, and examples, and repoints go-openai from
sashabaranov to github.com/hanzoai/go-openai v1.41.0 (required directly, no
replace directives anywhere).
Co-authored-by: Hanzo Dev <[email protected]>
49 lines
957 B
Go
49 lines
957 B
Go
package openairt_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"math"
|
|
"math/big"
|
|
"net"
|
|
"testing"
|
|
|
|
openairt "github.com/hanzoai/go-openai-realtime"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIntOrInfMarshalJSON(t *testing.T) {
|
|
v := openairt.IntOrInf(10)
|
|
require.Equal(t, 10, int(v))
|
|
require.False(t, v.IsInf())
|
|
|
|
b, err := json.Marshal(v)
|
|
require.NoError(t, err)
|
|
require.Equal(t, []byte("10"), b)
|
|
|
|
v = openairt.Inf
|
|
require.Equal(t, math.MaxInt, int(v))
|
|
require.True(t, v.IsInf())
|
|
|
|
b, err = json.Marshal(v)
|
|
require.NoError(t, err)
|
|
require.Equal(t, []byte("\"inf\""), b)
|
|
|
|
type TestStruct struct {
|
|
MaxOutputTokens openairt.IntOrInf `json:"max_output_tokens,omitempty"`
|
|
}
|
|
|
|
s := TestStruct{}
|
|
b, err = json.Marshal(s)
|
|
require.NoError(t, err)
|
|
require.Equal(t, []byte("{}"), b)
|
|
}
|
|
|
|
func TestInetAton(t *testing.T) {
|
|
ip := "37.57.95.27"
|
|
ret := big.NewInt(0)
|
|
i := net.ParseIP(ip).To4()
|
|
require.NotNil(t, i)
|
|
ret.SetBytes(i)
|
|
t.Log(ret.Uint64())
|
|
}
|