github.com/jgbaldwinbrown/perf@v0.1.1/benchproc/nonsingular_test.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package benchproc 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestNonSingularFields(t *testing.T) { 13 s, _ := mustParse(t, ".config") 14 15 var keys []Key 16 check := func(want ...string) { 17 t.Helper() 18 got := NonSingularFields(keys) 19 var gots []string 20 for _, f := range got { 21 gots = append(gots, f.Name) 22 } 23 if !reflect.DeepEqual(want, gots) { 24 t.Errorf("want %v, got %v", want, gots) 25 } 26 } 27 28 keys = []Key{} 29 check() 30 31 keys = []Key{ 32 p(t, s, "", "a", "1", "b", "1"), 33 } 34 check() 35 36 keys = []Key{ 37 p(t, s, "", "a", "1", "b", "1"), 38 p(t, s, "", "a", "1", "b", "1"), 39 p(t, s, "", "a", "1", "b", "1"), 40 } 41 check() 42 43 keys = []Key{ 44 p(t, s, "", "a", "1", "b", "1"), 45 p(t, s, "", "a", "2", "b", "1"), 46 } 47 check("a") 48 49 keys = []Key{ 50 p(t, s, "", "a", "1", "b", "1"), 51 p(t, s, "", "a", "2", "b", "1"), 52 p(t, s, "", "a", "1", "b", "2"), 53 } 54 check("a", "b") 55 }