-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils_test.go
69 lines (61 loc) · 1.36 KB
/
utils_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package htmx_test
import (
"testing"
htmx "github.com/zeiss/fiber-htmx"
"github.com/stretchr/testify/assert"
)
func TestMerge(t *testing.T) {
tests := []struct {
name string
in []htmx.ClassNames
out htmx.ClassNames
}{
{
name: "merge",
in: []htmx.ClassNames{
{"a": true, "b": false},
{"b": true, "c": false},
},
out: htmx.ClassNames{"a": true, "b": true, "c": false},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.out, htmx.Merge(tt.in...))
})
}
}
func BenchmarkMerge(b *testing.B) {
classNames := []htmx.ClassNames{
{"a": true, "b": false},
{"b": true, "c": false},
{"c": true, "d": false},
{"d": true, "e": false},
{"e": true, "f": false},
{"f": true, "g": false},
{"g": true, "h": false},
{"h": true, "i": false},
{"i": true, "j": false},
{"j": true, "k": false},
{"k": true, "l": false},
{"l": true, "m": false},
{"m": true, "n": false},
{"n": true, "o": false},
{"o": true, "p": false},
{"p": true, "q": false},
{"q": true, "r": false},
{"r": true, "s": false},
{"s": true, "t": false},
{"t": true, "u": false},
{"u": true, "v": false},
{"v": true, "w": false},
{"w": true, "x": false},
{"x": true, "y": false},
{"y": true, "z": false},
{"z": true, "a": false},
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
htmx.Merge(classNames...)
}
}