package usecase import ( "testing" "github.com/go-playground/assert/v2" "github.com/shopspring/decimal" ) // 測試 Int64Ptr 函數 func TestInt64Ptr(t *testing.T) { tests := []struct { name string val int64 want *int64 }{ { name: "non-zero value", val: 123, want: func() *int64 { v := int64(123); return &v }(), }, { name: "zero value", val: 0, want: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := Int64Ptr(tt.val) assert.Equal(t, tt.want, got) }) } } // 測試 DecimalToStringPtr 函數 func TestDecimalToStringPtr(t *testing.T) { tests := []struct { name string val *decimal.Decimal want *string }{ { name: "non-nil decimal", val: func() *decimal.Decimal { d := decimal.NewFromFloat(123.45); return &d }(), want: func() *string { s := "123.45"; return &s }(), }, { name: "nil decimal", val: nil, want: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := DecimalToStringPtr(tt.val) assert.Equal(t, tt.want, got) }) } } // 測試 StringPtr 函數 func TestStringPtr(t *testing.T) { tests := []struct { name string val string want *string }{ { name: "non-empty string", val: "test", want: func() *string { s := "test"; return &s }(), }, { name: "empty string", val: "", want: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := StringPtr(tt.val) assert.Equal(t, tt.want, got) }) } }