(t *testing.T)
| 5 | import "testing" |
| 6 | |
| 7 | func TestRandomizedGroups(t *testing.T) { |
| 8 | s := []string{"a", "b", "c", "d", "e", "f", "g", "h"} |
| 9 | n := 2 |
| 10 | |
| 11 | got := RandomizedGroups(s, n) |
| 12 | |
| 13 | if len(got) != 4 { |
| 14 | t.Errorf("expected: %v, got: %v", 4, len(got)) |
| 15 | } |
| 16 | |
| 17 | for _, group := range got { |
| 18 | if len(group) != 2 { |
| 19 | t.Errorf("expected: %v, got: %v", 2, len(group)) |
| 20 | } |
| 21 | |
| 22 | for _, item := range group { |
| 23 | found := false |
| 24 | for i, element := range s { |
| 25 | if item == element { |
| 26 | found = true |
| 27 | s[i] = "-1" |
| 28 | break |
| 29 | } |
| 30 | } |
| 31 | if !found { |
| 32 | t.Errorf("element %v not found in original slice", item) |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestPercentilesFloat64Reverse(t *testing.T) { |
| 39 | xs := []float64{5 * 1024 * 1024, 2 * 1024 * 1024, 1 * 1024 * 1024, 3 * 1024 * 1024, 4 * 1024 * 1024} |
nothing calls this directly
no test coverage detected