MCPcopy Create free account
hub / github.com/Azure/peerd / TestRandomizedGroups

Function TestRandomizedGroups

tests/random/math/math_test.go:7–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5import "testing"
6
7func 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
38func TestPercentilesFloat64Reverse(t *testing.T) {
39 xs := []float64{5 * 1024 * 1024, 2 * 1024 * 1024, 1 * 1024 * 1024, 3 * 1024 * 1024, 4 * 1024 * 1024}

Callers

nothing calls this directly

Calls 1

RandomizedGroupsFunction · 0.85

Tested by

no test coverage detected