package api import "testing" func TestRoundRatio(t *testing.T) { for _, c := range []struct{ in, want float64 }{ {1, 1}, {-1, -1}, {0, 0}, {0.99930555555556, 0.999306}, {0.99, 0.99}, // One failure in millions still is not 100%. {0.9999997, 0.999999}, } { if got := roundRatio(c.in); got != c.want { t.Errorf("roundRatio(%v) = %v, want %v", c.in, got, c.want) } } }