tp_test.go 1005 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import "testing"
  3. func TestRenderPercentage(t *testing.T) {
  4. var percentage float64
  5. percentage = 91.8948715
  6. if renderPercentage(percentage) != "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░░░" {
  7. t.Errorf("renderPercentage(%f)", percentage)
  8. }
  9. percentage = 15.8682051
  10. if renderPercentage(percentage) != "▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░" {
  11. t.Errorf("renderPercentage(%f)", percentage)
  12. }
  13. }
  14. func TestCalcPercentageFloat64(t *testing.T) {
  15. var full float64
  16. var part float64
  17. full = 100
  18. part = 50
  19. if calcPercentageFloat64(full, part) != 50 {
  20. t.Errorf("calcPercentageFloat64(%f,%f) test failed", full, part)
  21. }
  22. full = 8000
  23. part = 2000
  24. if calcPercentageFloat64(full, part) != 25 {
  25. t.Errorf("calcPercentageFloat64(%f,%f) test failed", full, part)
  26. }
  27. }