Browse Source

Add test for Scale() (#227)

38elements 7 years ago
parent
commit
cbc9b99bae
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      internal/measurement/measurement_test.go

+ 3
- 0
internal/measurement/measurement_test.go View File

35
 		{1024, "tb", "pb", 1, "PB"},
35
 		{1024, "tb", "pb", 1, "PB"},
36
 		{2048, "mb", "auto", 2, "GB"},
36
 		{2048, "mb", "auto", 2, "GB"},
37
 		{3.1536e7, "s", "auto", 1, "yrs"},
37
 		{3.1536e7, "s", "auto", 1, "yrs"},
38
+		{-1, "s", "ms", -1000, "ms"},
39
+		{1, "foo", "count", 1, ""},
40
+		{1, "foo", "bar", 1, "bar"},
38
 	} {
41
 	} {
39
 		if gotValue, gotUnit := Scale(tc.value, tc.fromUnit, tc.toUnit); gotValue != tc.wantValue || gotUnit != tc.wantUnit {
42
 		if gotValue, gotUnit := Scale(tc.value, tc.fromUnit, tc.toUnit); gotValue != tc.wantValue || gotUnit != tc.wantUnit {
40
 			t.Errorf("Scale(%d, %q, %q) = (%f, %q), want (%f, %q)",
43
 			t.Errorf("Scale(%d, %q, %q) = (%f, %q), want (%f, %q)",