package giftdiamond import "testing" func TestDefaultReturnCoinRatioPercentByGiftType(t *testing.T) { cases := map[string]string{ "normal": "30.00", "lucky": "10.00", "super_lucky": "1.00", "": "30.00", } for giftType, want := range cases { if got := defaultReturnCoinRatioPercent(giftType); got != want { t.Fatalf("defaultReturnCoinRatioPercent(%q) = %s, want %s", giftType, got, want) } } } func TestFormatReturnCoinRatioUsesGiftTypeDefault(t *testing.T) { if got := formatPercentStringWithDefault("", defaultReturnCoinRatioPercent("normal")); got != "30.00" { t.Fatalf("normal return coin fallback = %s, want 30.00", got) } if got := formatPercentStringWithDefault("12.345", defaultReturnCoinRatioPercent("lucky")); got != "12.35" { t.Fatalf("return coin rounding = %s, want 12.35", got) } }