diff --git a/http/good_temp.go b/http/good_temp.go index 1fde50a..c3f6b2d 100644 --- a/http/good_temp.go +++ b/http/good_temp.go @@ -21,6 +21,9 @@ func tempPercent(value, max int) int { // Function to calculate a partial radius, depending on a percentage value func tempProcessRadius(value, max, radius int) float64 { + if value >= max { + return 0 + } return (1 - float64(value)/float64(max)) * float64(radius) * 2 * 3.14 } diff --git a/http/good_temp_test.go b/http/good_temp_test.go index 0484c90..afd411f 100644 --- a/http/good_temp_test.go +++ b/http/good_temp_test.go @@ -16,4 +16,7 @@ func TestTempFuncs(t *testing.T) { // TODO is there a other way to calc this? resultFloat := tempProcessRadius(3, 9, 0) assert.Equal(float64(0), resultFloat) + + resultFloat = tempProcessRadius(12, 9, 10) + assert.Equal(float64(0), resultFloat) }