bindbox-game/internal/pkg/points/convert_test.go

25 lines
553 B
Go
Executable File

package points
import "testing"
func TestCentsToPoints_DefaultRate(t *testing.T) {
if got := CentsToPoints(100, 1); got != 1 {
t.Fatalf("expected 1, got %d", got)
}
}
func TestPointsToCents_DefaultRate(t *testing.T) {
if got := PointsToCents(1, 1); got != 100 {
t.Fatalf("expected 100, got %d", got)
}
}
func TestRefundPointsAmount(t *testing.T) {
// 100 Points used. Refund 25 Yuan out of 100 Yuan paid.
// Expect 25 Points back.
pts := RefundPointsAmount(100, 2500, 10000, 1)
if pts != 25 {
t.Fatalf("expected 25, got %d", pts)
}
}