-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlift_test.go
52 lines (42 loc) · 952 Bytes
/
lift_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
package lift_test
import (
"testing"
"github.com/AndrewHarrisSPU/lift"
)
// Ensure that MustUnwrap, MustUnwrapAs generate panics
func TestMustPanic(t *testing.T) {
testMustPanic(t, func() {
lift.MustUnwrap[struct{}](lift.Wrap(any(nil)))
})
testMustPanic(t, func() {
lift.MustUnwrapAs[struct{}](lift.Wrap(any(nil)))
})
}
func testMustPanic(t *testing.T, fn func()) {
t.Helper()
defer func() {
if r := recover(); r == nil {
t.Errorf("missing panic")
}
}()
fn()
}
// Quick testing for Map methods with no examples
func TestMapExtra(t *testing.T) {
m := lift.NewMap[struct{}]()
m.Store(
lift.Def[int](struct{}{}),
lift.Def[uint](struct{}{}),
lift.Def[byte](struct{}{}),
lift.Def[rune](struct{}{}),
)
keys := m.Keys()
entries := m.Entries()
if len(keys) != len(entries) || len(keys) != m.Len() {
t.Errorf("Map method failure")
}
m.Delete(m.Keys()...)
if m.Len() != 0 {
t.Errorf("Map method failure")
}
}