37 lines
1005 B
Go
37 lines
1005 B
Go
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)
|
|
}
|
|
|
|
}
|