package utils

import (
	"testing"
)

func TestToFloat64(t *testing.T) {
	tests := []struct {
		name    string
		input   interface{}
		wantVal float64
		wantOK  bool
	}{
		{"float64", float64(3.14), 3.14, true},
		{"float32", float32(2.5), 2.5, true},
		{"int", int(42), 42.0, true},
		{"int64", int64(100), 100.0, true},
		{"int32", int32(7), 7.0, true},
		{"numeric string", "3.14", 3.14, true},
		{"int string", "42", 42.0, true},
		{"non-numeric string", "abc", 0, false},
		{"empty string", "", 0, false},
		{"nil", nil, 0, false},
		{"bool", true, 0, false},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			gotVal, gotOK := ToFloat64(tt.input)
			if gotVal != tt.wantVal || gotOK != tt.wantOK {
				t.Errorf("ToFloat64(%v) = (%v, %v), want (%v, %v)",
					tt.input, gotVal, gotOK, tt.wantVal, tt.wantOK)
			}
		})
	}
}
