Make test of all the fixed value functions
This commit is contained in:
parent
1cd285635f
commit
70fe89228d
36
tp_test.go
Normal file
36
tp_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRenderPercentage(t *testing.T) {
|
||||
var percentage float64
|
||||
|
||||
percentage = 91.8948715
|
||||
if renderPercentage(percentage) != "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░░░" {
|
||||
t.Errorf("renderPercentage(%f)", percentage)
|
||||
}
|
||||
|
||||
percentage = 15.8682051
|
||||
if renderPercentage(percentage) != "▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░" {
|
||||
t.Errorf("renderPercentage(%f)", percentage)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCalcPercentageFloat64(t *testing.T) {
|
||||
var full float64
|
||||
var part float64
|
||||
|
||||
full = 100
|
||||
part = 50
|
||||
if calcPercentageFloat64(full, part) != 50 {
|
||||
t.Errorf("calcPercentageFloat64(%f,%f) test failed", full, part)
|
||||
}
|
||||
|
||||
full = 8000
|
||||
part = 2000
|
||||
if calcPercentageFloat64(full, part) != 25 {
|
||||
t.Errorf("calcPercentageFloat64(%f,%f) test failed", full, part)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user