Sfoglia il codice sorgente

Make test of all the fixed value functions

Sacha Ligthert 3 anni fa
parent
commit
70fe89228d
1 ha cambiato i file con 36 aggiunte e 0 eliminazioni
  1. 36 0
      tp_test.go

+ 36 - 0
tp_test.go

@@ -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)
+	}
+
+}