package flyto import "testing" // TestFloat_RoundTrip 锁 Float helper 的语义: 返回的指针 deref 等于输入, // 且不同调用之间互不影响 (各自独立的 backing storage). // // TestFloat_RoundTrip locks the Float helper semantics: the returned // pointer dereferences to the input value, and successive calls produce // independent backing storage. func TestFloat_RoundTrip(t *testing.T) { cases := []float64{0, 0.7, 1.0, 1.5, 2.0} for _, v := range cases { p := Float(v) if p == nil { t.Errorf("Float(%v) returned nil", v) continue } if *p != v { t.Errorf("*Float(%v) = %v, want %v", v, *p, v) } } // 不同调用独立 backing storage; mutate 一个不影响另一个. p1 := Float(0.5) p2 := Float(0.5) *p1 = 1.0 if *p2 != 0.5 { t.Errorf("Float() shares backing storage: p2=%v after mutating p1", *p2) } } // TestRequest_TemperatureTopP_Nil 锁 Request 默认状态: 未设 Temperature/TopP // 时字段为 nil (passthrough policy 的默认行为, wire 层 omitempty 不传). // // TestRequest_TemperatureTopP_Nil locks the default state: an unset // Temperature/TopP is nil, which the wire layer omits via omitempty. func TestRequest_TemperatureTopP_Nil(t *testing.T) { req := &Request{Model: "x"} if req.Temperature != nil { t.Errorf("default Request.Temperature = %v, want nil", *req.Temperature) } if req.TopP != nil { t.Errorf("default Request.TopP = %v, want nil", *req.TopP) } }