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