genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] fix max value in availablity funktion

This commit is contained in:
Martin Geno 2017-06-23 12:59:58 +02:00
parent 157431d425
commit 0cfa486c95
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
2 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,9 @@ func tempPercent(value, max int) int {
// Function to calculate a partial radius, depending on a percentage value // Function to calculate a partial radius, depending on a percentage value
func tempProcessRadius(value, max, radius int) float64 { func tempProcessRadius(value, max, radius int) float64 {
if value >= max {
return 0
}
return (1 - float64(value)/float64(max)) * float64(radius) * 2 * 3.14 return (1 - float64(value)/float64(max)) * float64(radius) * 2 * 3.14
} }

View File

@ -16,4 +16,7 @@ func TestTempFuncs(t *testing.T) {
// TODO is there a other way to calc this? // TODO is there a other way to calc this?
resultFloat := tempProcessRadius(3, 9, 0) resultFloat := tempProcessRadius(3, 9, 0)
assert.Equal(float64(0), resultFloat) assert.Equal(float64(0), resultFloat)
resultFloat = tempProcessRadius(12, 9, 10)
assert.Equal(float64(0), resultFloat)
} }