2023-10-24 08:05:33 +00:00
|
|
|
package reload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFlushMapVal(t *testing.T) {
|
|
|
|
t.Run("t1", func(t *testing.T) {
|
2023-10-27 12:51:46 +00:00
|
|
|
c := 0
|
2023-12-20 14:30:55 +00:00
|
|
|
v := GetAnyValMapBy("key", 2, struct{}{}, func(a struct{}) (int, bool) {
|
2023-10-27 12:51:46 +00:00
|
|
|
c++
|
2023-12-20 14:30:55 +00:00
|
|
|
return 33, true
|
2023-10-24 08:05:33 +00:00
|
|
|
})
|
|
|
|
fmt.Println(v)
|
2024-01-18 15:29:50 +00:00
|
|
|
DeleteMapVal("key", 2)
|
2023-10-24 08:05:33 +00:00
|
|
|
|
2023-12-20 14:30:55 +00:00
|
|
|
v = GetAnyValMapBy("key", 2, struct{}{}, func(a struct{}) (int, bool) {
|
2023-10-24 08:05:33 +00:00
|
|
|
fmt.Println("xxxxx")
|
2023-12-20 14:30:55 +00:00
|
|
|
return 33, true
|
2023-10-24 08:05:33 +00:00
|
|
|
})
|
|
|
|
fmt.Println(v)
|
|
|
|
FlushAnyVal("key")
|
2023-12-20 14:30:55 +00:00
|
|
|
v = GetAnyValMapBy[int, int, struct{}]("key", 2, struct{}{}, func(a struct{}) (int, bool) {
|
2023-10-24 08:05:33 +00:00
|
|
|
fmt.Println("yyyy")
|
2023-12-20 14:30:55 +00:00
|
|
|
return 33, true
|
2023-10-24 08:05:33 +00:00
|
|
|
})
|
|
|
|
fmt.Println(v)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetAnyMapFnBys(t *testing.T) {
|
|
|
|
var i int
|
|
|
|
t.Run("t1", func(t *testing.T) {
|
2024-01-18 15:29:50 +00:00
|
|
|
v := BuildMapFnWithConfirm[int]("name", func(a int) (int, bool) {
|
2023-10-24 08:05:33 +00:00
|
|
|
i++
|
2024-01-18 15:29:50 +00:00
|
|
|
return a + 1, true
|
2023-10-24 08:05:33 +00:00
|
|
|
})
|
|
|
|
vv := v(1, 2)
|
|
|
|
vvv := v(2, 3)
|
|
|
|
fmt.Println(vv, vvv)
|
|
|
|
v(1, 2)
|
2024-01-18 15:29:50 +00:00
|
|
|
DeleteMapVal("name", 2)
|
2023-10-24 08:05:33 +00:00
|
|
|
v(2, 3)
|
|
|
|
fmt.Println(i)
|
|
|
|
})
|
|
|
|
}
|